Skip to content

Fix Android TextInput accessibilityLabel using hintText instead of contentDescription - #60585

Open
jwlilly wants to merge 1 commit into
react:mainfrom
jwlilly:fix/android-textinput-accessibility-label
Open

jwlilly wants to merge 1 commit into
react:mainfrom
jwlilly:fix/android-textinput-accessibility-label

Conversation

@jwlilly

@jwlilly jwlilly commented Dec 5, 2026 •

Copy link
Copy Markdown

Summary:

On Android, EditText does not support contentDescription as an accessible label:

  • TalkBack ignores contentDescription once text is entered into the field, so accessibilityLabel is no longer announced when refocusing a populated TextInput.
  • When both accessibilityLabel and placeholder are set, TalkBack prioritizes the native hintText (placeholder) when the field is empty, overriding accessibilityLabel.

This change updates Android accessibility handling for EditText:

  • In BaseViewManager.updateViewContentDescription, skip setting contentDescription on EditText (clearing it to null).
  • In ReactAccessibilityDelegate.onInitializeAccessibilityNodeInfo, when host is EditText and R.id.accessibility_label is non-empty, expose it via info.hintText, set info.isShowingHintText = host.text.isNullOrEmpty(), and set info.text = accessibilityLabel only when empty (matching AOSP TextView behavior so accessibilityLabel overrides placeholder in the accessibility node without altering the visual placeholder or entered/password text). Always clear info.contentDescription = null and skip the fallback getTalkbackDescription assignment for EditText.
  • In ReactAccessibilityDelegate.setDelegate, attach the delegate when an EditText has R.id.accessibility_label.

Fixes #55004

Changelog:

[ANDROID] [FIXED] - Map accessibilityLabel on Android TextInput to AccessibilityNodeInfo.hintText instead of contentDescription so TalkBack announces it when filled and when combined with placeholder.

Test Plan:

  1. Added unit tests in ReactAccessibilityDelegateTest and ReactTextInputPropertyTest covering empty and populated EditText, accessibilityLabel combined with placeholder, secureTextEntry, clearing accessibilityLabel, and ensuring contentDescription is not set.
  2. Ran Android unit tests:
    ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest \
      --tests "com.facebook.react.uimanager.*" \
      --tests "com.facebook.react.views.*"
    All tests passed.
  3. Verified Kotlin and Java formatting with ktfmt (node scripts/format-kotlin.js --dry-run) and google-java-format.
  4. Tested in RNTester on an Android 16 (API 36) emulator with TalkBack across empty/filled TextInput fields with accessibilityLabel, placeholder, and secureTextEntry:
    • Empty TextInput with accessibilityLabel only: visually blank; TalkBack announces accessibilityLabel.
    • Populated TextInput with accessibilityLabel only: TalkBack announces the entered value and Edit box, <accessibilityLabel>.
    • Empty TextInput with both accessibilityLabel and placeholder: visually renders placeholder; TalkBack announces accessibilityLabel.
    • Populated TextInput with both accessibilityLabel and placeholder: TalkBack announces entered value and accessibilityLabel.
    • TextInput with secureTextEntry and accessibilityLabel: TalkBack announces Editing, password, <N> characters, Edit box, <accessibilityLabel>.
    • TextInput with placeholder only: unchanged native behavior.
issue-55004-talkback-demo.mp4

…ntentDescription

On Android, EditText does not support contentDescription for accessible labels; TalkBack ignores contentDescription once text is entered and prioritizes placeholder hint text when both are present.

Map accessibilityLabel on EditText views to AccessibilityNodeInfoCompat.hintText (and sync text/isShowingHintText when empty) in ReactAccessibilityDelegate, and avoid setting contentDescription on EditText in BaseViewManager and ReactAccessibilityDelegate.

Fixes react#55004
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 5, 2026
@jwlilly
jwlilly marked this pull request as ready for review December 5, 2026 00:23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] - accessibilityLabel ignored on TextInput when testing with TalkBack screen reader (and also placeholder overriding accessibilityLabel)

1 participant