[Android] Make detector aware of child transform#4251
Open
m-bert wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts Android touch-handler extraction for v3 GestureDetector so a native detector with a single transformed child (e.g. translateX in ReanimatedSwipeable) doesn’t incorrectly record/activate its own handlers over areas where its content has moved away, addressing #4250 while preserving the hitSlop behavior from #4049.
Changes:
- Extends
recordViewHandlersForPointerto optionally bounds-check handlers in a detector’s single child coordinate space. - Updates the
BOX_NONEtraversal path to use the child-space bounds check only forRNGestureHandlerDetectorViewwhen no child handled the touch.
💡 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
Since 3.0 the v3 GestureDetector is a host component whose native frame is the bounding box of its children's layout frames.
ReanimatedSwipeableonly moves the row viatransform: translateX, which doesn't affect layout. InGestureHandlerOrchestrator, theBOX_NONEbranch force-records a detector's own handlers even when no child is hit, so a press on a revealed button was tracked by tap-to-close, which then activated first and cancelled the button.This PR makes the force-record path transform-aware: for a single-child detector, handler bounds are now checked in the child's (transformed) coordinate space instead of the detector's own frame. With an identity transform the child fills the detector, so the behavior — and hitSlop expansion (#4049) — is unchanged; with a translated child the interactive area follows the content, so it no longer steals presses over revealed siblings.
Fixes #4250
Test plan
Tested on expo-example (Reanimated Swipeable, Transformations, etc.)