Skip to content

Comments

Fix some text field accessibility issues#2553

Merged
m-sasha merged 2 commits intojb-mainfrom
m-sasha/fix-textfield-a11y
Nov 5, 2025
Merged

Fix some text field accessibility issues#2553
m-sasha merged 2 commits intojb-mainfrom
m-sasha/fix-textfield-a11y

Conversation

@m-sasha
Copy link

@m-sasha m-sasha commented Nov 5, 2025

Fix several text field accessibility issues:

  1. Report scrollable text nodes as having TEXT role, rather than SCROLL_PANE. This fixes accessibility for BTF2.
  2. Add AccessibleState.EDITABLE to editable text fields.
  3. Correctly return getSelectionStart and getSelectionEnd for inverted selection.
  4. Correctly return getSelectedText() as null when there is no selection.
  5. Fire ACCESSIBLE_TEXT_PROPERTY property change event with the position rather than the text, as AccessibleJTextComponent does.
  6. Fire ACCESSIBLE_SELECTION_PROPERTY when the selection changes.

Fixes https://youtrack.jetbrains.com/issue/CMP-7461
Fixes https://youtrack.jetbrains.com/issue/CMP-9229

Testing

Tested manually and added unit tests.

fun main() = singleWindowApplication {
    TextFields()
}

@Composable
private fun TextFields() {
    Column(
        modifier = Modifier.fillMaxSize().padding(16.dp),
    ) {
        Text("TextField1 1")
        var text1 by remember { mutableStateOf("") }
        TextField(
            value = text1,
            onValueChange = { text1 = it },
        )

        Spacer(Modifier.height(64.dp))
        Text("TextField2")
        val textFieldState = rememberTextFieldState()
        TextField(state = textFieldState)

        Spacer(Modifier.height(64.dp))
        Text("JTextField 1")
        SwingPanel(
            factory = {
                JTextField()
            },
            modifier = Modifier
                .size(500.dp, 60.dp)
        )
    }
}

This should be tested by QA

Release Notes

Fixes - Desktop

  • Fix the accessibility issue where screen readers cannot review text in a text field
  • Fix the accessibility issue where scrollable text fields are not accessible for screen readers

@m-sasha m-sasha requested a review from igordmn November 5, 2025 13:54
@m-sasha m-sasha merged commit 7c5eb14 into jb-main Nov 5, 2025
16 checks passed
@m-sasha m-sasha deleted the m-sasha/fix-textfield-a11y branch November 5, 2025 19:00
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