Fix Android Pressable TalkBack activation#4213
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds Android-specific accessibility actions to both v3 Pressable and legacy Pressable, routing activate/longpress accessibility actions into the existing press lifecycle, and introduces helpers + tests to validate the behavior.
Changes:
- Add default
accessibilityActions(activate/longpress) on Android when press handlers are present, without overriding user-provided actions. - Handle
onAccessibilityActionby triggering press lifecycle / long-press callbacks when the user hasn’t explicitly handled the action. - Add shared utilities for default action generation + synthetic press events, plus new Jest tests for both implementations.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/v3/components/Pressable.tsx | Adds Android accessibility actions + handler wiring to v3 Pressable. |
| packages/react-native-gesture-handler/src/components/Pressable/utils.ts | Introduces helpers for default accessibility actions and synthetic press events. |
| packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx | Adds the same Android accessibility actions + handler wiring to legacy Pressable. |
| packages/react-native-gesture-handler/src/tests/Pressable.accessibility.test.tsx | Adds test coverage for activate/longpress behavior across both implementations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2136c9c to
fc44fe1
Compare
|
I checked the linked fixes: #4220 and #4222 are both merged. This branch has also been updated to address the implementation/test concerns from Copilot: shared If #4220/#4222 fully cover the TalkBack issue from your side, I'm happy to close this as superseded; otherwise this PR is still ready for review as the explicit Pressable accessibility-action path. |
Description
Fixes #3899. Root-cause note: #3899 (comment)
TalkBack's double-tap activation dispatches an Android accessibility click/action to the native view rather than the touch stream consumed by
Pressable's gesture state machine. That means theFINALIZE -> handlePressOutpath that callsonPressis never reached. PR #4017 helped with touch-event ordering, but it does not cover this accessibility-action channel.This brings
PressableandLegacyPressableto parity with the existing touchables by:activateandlongpresswhen the corresponding press handlers exist;activatethrough the existingonPressIn->onPressOut->onPresslifecycle using synthetic layout-local press events;longpresstoonLongPress;onAccessibilityAction;onPresscalls for apps that already supplied their own user-handledactivateaction workaround;Test plan
yarn test Pressable.accessibility.test.tsxyarn testyarn ts-checkyarn lint:js(passes with existing repo warnings only)git diff --check