[Android] Set AccessibilityNodeInfo.stateDescription so TalkBack stops reading "checked. on." on switches
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 127k
- Forks
- 25.3k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
Description
On Android, a view with accessibilityRole="switch" and accessibilityState={{ checked: true }} is read by TalkBack as "checked. on.". TalkBack takes "on" from the Switch class name and "checked" from isChecked. It suppresses the generic word only when stateDescription is set (API 30+).
ReactAccessibilityDelegate.kt on main never calls setStateDescription: for STATE_CHECKED it sets only isCheckable and isChecked. No JS prop reaches stateDescription, so apps can't fix this without native code.
A related request, #34736 ("Custom State Descriptions"), was closed by the stale bot in 2023 without a PR.
Steps to reproduce
- Render
<Pressable accessibilityRole="switch" accessibilityState={{ checked: true }} accessibilityLabel="Notifications" />. - Turn on TalkBack and focus the element.
- Hear "checked. on." in the announcement.
Expected
The state is read once ("on"), not twice.
Suggested fix
In ReactAccessibilityDelegate, when accessibilityState.checked is set, also call ViewCompat.setStateDescription (or AccessibilityNodeInfoCompat.setStateDescription). For role switch it would be "on"/"off", and for role checkbox "checked"/"not checked", using Android's own localized strings. Alternatively, expose accessibilityValue.text as the stateDescription.
Versions
- React Native 0.85.3 (Expo SDK 56). Also confirmed on
mainup to v0.88.0-rc.1 by reading the source. - TalkBack 17.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ReactAccessibilityDelegate.kt, at the STATE_CHECKED handling, and trace how accessibilityRole and accessibilityState reach the Android node. Compare the suggested ViewCompat or AccessibilityNodeInfoCompat stateDescription behavior for switch and checkbox roles, then verify the announcement no longer repeats the state while existing accessibility behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin, react-native
- Domain
- accessibility, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100