react / react/react-native

[Android] Set AccessibilityNodeInfo.stateDescription so TalkBack stops reading "checked. on." on switches

Open
#58,588 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs: Author Feedback Needs: Repro
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
  1. Render <Pressable accessibilityRole="switch" accessibilityState={{ checked: true }} accessibilityLabel="Notifications" />.
  2. Turn on TalkBack and focus the element.
  3. 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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.