Fix Android Pressable TalkBack activation#4213
Open
sorinc03 wants to merge 2 commits into
Open
Conversation
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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