Skip to content

Conversation

@j-piasecki
Copy link
Member

Description

Addresses the underlying issue of #3906

The original issue described in the above PR was caused by wrong shadow node dimensions, which were fixed by #3930. After that, the dimensions were good, but the long press was still failing. This was caused by shouldCancelWhenOutside checking the dimensions of the detector while the child was moved.

This PR changes the logic so that the child's hitbox is checked when using the native detector. This should be enough for iOS, but on Android, further investigation is needed into whether the entire transformedEvent should be in the coordinate space of the detector or its child.

Test plan

See #3906 test plan

Copilot AI review requested due to automatic review settings January 30, 2026 12:49
Copy link
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

This PR adjusts how shouldCancelWhenOutside is evaluated for native/virtual detectors so that hit-testing follows the moving child view rather than the static detector wrapper, addressing the remaining issues from #3906 and #3930.

Changes:

  • On iOS, RNGestureHandler.containsPointInView now hit-tests against the detector’s child view when shouldCancelWhenOutside is enabled.
  • On Android, exposes GestureHandlerOrchestrator.transformPointToChildViewCoords and uses it in GestureHandler.handle to transform events into the detector child’s coordinate space for bounds checks.
  • Refactors the shouldCancelWhenOutside cancellation logic in GestureHandler.handle to use the new child-relative hit-test result.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/react-native-gesture-handler/apple/RNGestureHandler.mm Switches containsPointInView to hit-test the detector’s first subview when shouldCancelWhenOutside is set, so long-press/tap can track a moved child instead of the wrapper.
packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt Makes transformPointToChildViewCoords publicly accessible so other components (like GestureHandler) can compute child-relative coordinates.
packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt Uses RNGestureHandlerDetectorView’s first child and transformPointToChildViewCoords for isWithinBounds when using a detector, and updates the shouldCancelWhenOutside path to rely on that hit-test.

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

@j-piasecki j-piasecki changed the title [Native] Fix shoudlCancelWhenOutside not tracking the view [Native] Fix shouldCancelWhenOutside not tracking the view Jan 30, 2026
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.

2 participants