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
main up to v0.88.0-rc.1 by reading the source.
- TalkBack 17.
Description
On Android, a view with
accessibilityRole="switch"andaccessibilityState={{ checked: true }}is read by TalkBack as "checked. on.". TalkBack takes "on" from the Switch class name and "checked" fromisChecked. It suppresses the generic word only whenstateDescriptionis set (API 30+).ReactAccessibilityDelegate.ktonmainnever callssetStateDescription: forSTATE_CHECKEDit sets onlyisCheckableandisChecked. No JS prop reachesstateDescription, 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
<Pressable accessibilityRole="switch" accessibilityState={{ checked: true }} accessibilityLabel="Notifications" />.Expected
The state is read once ("on"), not twice.
Suggested fix
In
ReactAccessibilityDelegate, whenaccessibilityState.checkedis set, also callViewCompat.setStateDescription(orAccessibilityNodeInfoCompat.setStateDescription). For roleswitchit would be "on"/"off", and for rolecheckbox"checked"/"not checked", using Android's own localized strings. Alternatively, exposeaccessibilityValue.textas thestateDescription.Versions
mainup to v0.88.0-rc.1 by reading the source.