Skip to content

[General] Add yieldsToNativeGestures property to native gesture#4135

Merged
j-piasecki merged 12 commits intomainfrom
@jpiasecki/yields-to-native-gestures
May 4, 2026
Merged

[General] Add yieldsToNativeGestures property to native gesture#4135
j-piasecki merged 12 commits intomainfrom
@jpiasecki/yields-to-native-gestures

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

Description

Currently, NativeViewGestureHandler exposes disallowInterruption property, which causes it to cancel all other gestures upon activation. This is great for the Touchable component, since it shouldn't allow other gesture handlers to activate when it's pressed. The issue with that was the fact that disallowInterruption means that all native gestures are cancelled as well, including ScrollView or any other custom container, making Touchable not usable in real use-cases.

This PR adds yieldsToNativeGestures property, which works only when disallowInterruption is true. It defaults to false, where it behaves as disallowInterruption does currently. When set to true, it allows the gesture to be canceled by other native gestures but not any other type of gesture.

Touchable is now using this new config to make it work inside scrollable containers.

Test plan

Changed RectButtons with Touchables in the common app

- Before After
Android
Screen.Recording.2026-04-30.at.08.07.55.mov
Screen.Recording.2026-04-30.at.08.06.28.mov
iOS
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-04-30.at.08.08.29.mov
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-04-30.at.08.07.20.mov

Since scrolling on web dispatches pointercancel event, this prop is effectively a no-op for Touchable.

Copilot AI review requested due to automatic review settings April 30, 2026 06:52
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

Adds a new yieldsToNativeGestures configuration option to the “native” gesture so disallowInterruption can still block RNGH gestures (Pan/Tap/etc.) while allowing native containers (e.g., ScrollView) to take over—fixing Touchable usability inside scrollables.

Changes:

  • Introduces yieldsToNativeGestures config across web + v3 native gesture typings and documentation.
  • Implements platform behavior changes (web/iOS/Android) to allow yielding to native gestures when disallowInterruption is enabled.
  • Updates v3 Touchable to opt into yieldsToNativeGestures: true.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/react-native-gesture-handler/src/web/interfaces.ts Adds yieldsToNativeGestures to web handler config typing.
packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts Updates web native-handler interaction logic to optionally yield to other native handlers.
packages/react-native-gesture-handler/src/v3/hooks/gestures/native/NativeTypes.ts Exposes the new property in v3 Native gesture types and native-prop allowlist.
packages/react-native-gesture-handler/src/v3/components/Touchable/Touchable.tsx Enables yielding for v3 Touchable by default.
packages/react-native-gesture-handler/apple/RNGestureHandler.mm Moves the UIGestureRecognizer category interface out (implementation remains here).
packages/react-native-gesture-handler/apple/RNGestureHandler.h Declares gestureHandler category in a header so other files can use it.
packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.mm Implements yielding behavior by not cancelling native/non-RNGH and dummy recognizers when configured.
packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt Adjusts cancellation policy to respect yielding for native/root-native handlers.
packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt Adds new flag + updates simultaneous/cancellation behavior (needs a fix noted in review comment).
packages/docs-gesture-handler/docs/gestures/use-native-gesture.mdx Documents yieldsToNativeGestures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@j-piasecki j-piasecki requested a review from m-bert April 30, 2026 07:23
Comment thread packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.mm Outdated
Copy link
Copy Markdown
Collaborator

@m-bert m-bert left a comment

Choose a reason for hiding this comment

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

LGTM

@j-piasecki j-piasecki merged commit 3c4d189 into main May 4, 2026
10 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/yields-to-native-gestures branch May 4, 2026 12:19
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.

3 participants