Commit 626568f
fix(android): Stabilize custom accessibility action IDs for TalkBack (#52724)
Summary:
This pull request resolves a critical accessibility bug on Android where custom `accessibilityActions` fail to execute when activated via TalkBack's swipe gestures.
**The Problem:**
- When a user focuses a component with custom `accessibilityActions` (like a `TouchableOpacity`), TalkBack correctly announces the action labels as the user swipes up or down.
- However, when the user double-taps to activate the selected action, TalkBack reports an "incompatible action," and the `onAccessibilityAction` event is never triggered.
**The Root Cause:**
The investigation revealed that the `ReactAccessibilityDelegate` was generating **new, unstable IDs** for custom actions on every UI update. This instability prevents the Android accessibility service from reliably tracking and invoking the selected action.
**The Solution:**
This change introduces a static, thread-safe cache (`ConcurrentHashMap`) within `ReactAccessibilityDelegate`. This ensures that each unique action name is mapped to a single, stable ID for the entire lifecycle of the application. This provides the consistency required by TalkBack to function correctly.
This addresses the issue described in #47268.
---
## Changelog:
[Android] [Fixed] - Stabilize custom accessibility action IDs to prevent "incompatible action" errors in TalkBack.
---
Pull Request resolved: #52724
Test Plan:
The fix was validated extensively using the RNTester app on a physical Android device and an Android emulator.
### Steps to Reproduce (Before Fix)
1. Enable TalkBack on an Android device.
2. Navigate to a `TouchableOpacity` component with several custom `accessibilityActions`.
3. Swipe up or down to cycle through the actions. TalkBack correctly announces them (e.g., "add to cart").
4. Double-tap to execute the selected action.
5. **Result (Bug):** TalkBack announces *"incompatible action"*, and the `onAccessibilityAction` event is not triggered.
### Validation Steps (After Fix)
1. Follow the same steps as above on the patched version.
2. **Result (Fixed):** After double-tapping, the `onAccessibilityAction` event is **correctly triggered** with the appropriate action name. The "incompatible action" issue is fully resolved.
*A screen recording demonstrating the successful fix can be provided if needed.*
Uploading fixed bugs view problems (1).mp4…
Fixes #47268
Reviewed By: jorge-cab
Differential Revision: D78737471
Pulled By: cipolleschi
fbshipit-source-id: 877b196597472ac6a4f6df81a05a43956fb346291 parent 2c540ac commit 626568f
1 file changed
Lines changed: 17 additions & 6 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager
Lines changed: 17 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
192 | 194 | | |
193 | 195 | | |
194 | 196 | | |
195 | | - | |
| 197 | + | |
| 198 | + | |
196 | 199 | | |
197 | | - | |
198 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
199 | 204 | | |
200 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
201 | 211 | | |
202 | | - | |
| 212 | + | |
| 213 | + | |
203 | 214 | | |
204 | 215 | | |
205 | 216 | | |
| |||
0 commit comments