[Android] Set AccessibilityNodeInfo.stateDescription so TalkBack stops reading "checked. on." on switches
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C++
- Estrellas
- 127k
- Forks
- 25.3k
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 4
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en ReactAccessibilityDelegate.kt, en el manejo de STATE_CHECKED, y sigue cómo accessibilityRole y accessibilityState llegan al nodo de Android. Compara el comportamiento sugerido de ViewCompat o AccessibilityNodeInfoCompat para stateDescription en los roles switch y checkbox; después, verifica que el anuncio ya no repita el estado mientras el comportamiento de accesibilidad existente permanece intacto.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- android, kotlin, react-native
- Área
- accessibility, mobile
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 68/100