Skip to content

Fix Android Pressable TalkBack activation#4213

Open
sorinc03 wants to merge 2 commits into
software-mansion:mainfrom
sorinc03:fix/android-pressable-onpress-talkback
Open

Fix Android Pressable TalkBack activation#4213
sorinc03 wants to merge 2 commits into
software-mansion:mainfrom
sorinc03:fix/android-pressable-onpress-talkback

Conversation

@sorinc03
Copy link
Copy Markdown
Contributor

@sorinc03 sorinc03 commented May 31, 2026

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 the FINALIZE -> handlePressOut path that calls onPress is never reached. PR #4017 helped with touch-event ordering, but it does not cover this accessibility-action channel.

This brings Pressable and LegacyPressable to parity with the existing touchables by:

  • adding default Android accessibility actions for activate and longpress when the corresponding press handlers exist;
  • routing activate through the existing onPressIn -> onPressOut -> onPress lifecycle using synthetic layout-local press events;
  • routing longpress to onLongPress;
  • preserving user-provided accessibility actions and forwarding onAccessibilityAction;
  • avoiding duplicate onPress calls for apps that already supplied their own user-handled activate action workaround;
  • sharing the Android accessibility-action wiring between the v3 and legacy implementations.

Test plan

  • yarn test Pressable.accessibility.test.tsx
  • yarn test
  • yarn ts-check
  • yarn lint:js (passes with existing repo warnings only)
  • git diff --check

Copilot AI review requested due to automatic review settings May 31, 2026 19:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 onAccessibilityAction by 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.

Comment thread packages/react-native-gesture-handler/src/v3/components/Pressable.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/components/Pressable/Pressable.tsx Outdated
Comment thread packages/react-native-gesture-handler/src/v3/components/Pressable.tsx Outdated
@sorinc03 sorinc03 marked this pull request as ready for review May 31, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pressable does not execute onPress on Android when TalkBack screen reader is enabled

2 participants