Skip to content

Comments

Fix Accessible hierarchy and initial focus#2637

Merged
m-sasha merged 17 commits intojb-mainfrom
m-sasha/fix-accessible-hierarchy
Dec 14, 2025
Merged

Fix Accessible hierarchy and initial focus#2637
m-sasha merged 17 commits intojb-mainfrom
m-sasha/fix-accessible-hierarchy

Conversation

@m-sasha
Copy link

@m-sasha m-sasha commented Dec 9, 2025

Fix the parent/child link between ComposeSceneAccessible and SkiaLayer (and SwingSkiaLayer).
Also make sure to fire a focused property change event when a newly created focused node.

Fixes https://youtrack.jetbrains.com/issue/CMP-9209
Fixes https://youtrack.jetbrains.com/issue/CMP-9236

Testing

Added several unit tests, and also tested with the following:

fun main() {
//    System.setProperty("compose.layers.type", "COMPONENT")
//    System.setProperty("compose.swing.render.on.graphics", "true")
//    swingMain()
    composeMain()
}

@Composable
private fun AppContent() {
    Column(Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(16.dp)) {
        Text("Hello, World!")
        Text("Hello, Compose!")

        val focusRequester = remember { FocusRequester() }
        Button(onClick = {}, Modifier.focusRequester(focusRequester)) { Text("Button 1") }
//        LaunchedEffect(Unit) { focusRequester.requestFocus() }
        Button(onClick = {}) { Text("Button 2") }
    }
}

fun composeMain() = singleWindowApplication {
    AppContent()
}

fun swingMain() = SwingUtilities.invokeLater {
    val frame = JFrame()
    val panel = ComposePanel()
    panel.setContent {
        AppContent()
    }
    frame.contentPane.add(panel)
    frame.size = Dimension(500, 500)
    frame.isVisible = true
}

This should be tested by QA

Release Notes

Fixes - Desktop

  • [A11y, Windows] Fixed the accessibility hierarchy, allowing NVDA traversal commands to work correctly.
  • [A11y] Correctly report focused status of a newly created, but already focused, node.
  • [A11y] Correctly re-report focused state of focused node when the Compose container becomes focused, such as when the window is brought to the foreground.

@m-sasha m-sasha requested a review from igordmn December 9, 2025 20:07
@m-sasha m-sasha force-pushed the m-sasha/fix-accessible-hierarchy branch from cfddb00 to 26ab153 Compare December 10, 2025 12:15
@m-sasha m-sasha requested review from igordmn and removed request for igordmn December 10, 2025 13:19
@m-sasha
Copy link
Author

m-sasha commented Dec 10, 2025

This needs more work to fix https://youtrack.jetbrains.com/issue/CMP-9236, so I'm converting it to a draft for now.

@m-sasha m-sasha marked this pull request as draft December 10, 2025 13:25
@m-sasha m-sasha force-pushed the m-sasha/fix-accessible-hierarchy branch from 26ab153 to f2ae53d Compare December 10, 2025 19:00
@m-sasha m-sasha marked this pull request as ready for review December 11, 2025 11:26
@m-sasha m-sasha requested a review from igordmn December 11, 2025 11:26
@m-sasha m-sasha force-pushed the m-sasha/fix-accessible-hierarchy branch from b182c9d to 357b601 Compare December 14, 2025 13:17
@m-sasha m-sasha merged commit d084d8a into jb-main Dec 14, 2025
16 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-accessible-hierarchy branch December 14, 2025 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants