[iOS] Fix InterceptingGestureDetector not recognizing gestures #4170
Merged
Conversation
InterceptingGestureDetector not recognizing gestures
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the native (iOS + Android) “virtual detector” hit-testing logic so VirtualGestureDetector can correctly decide whether the current touch should be attributed to a specific virtual view tag (e.g., inline/nested text targets) within the detector’s subtree.
Changes:
- iOS: add a recursive subtree search that uses
touchEventEmitterAtPoint:to detect whether a touch corresponds to a givenvirtualViewTag. - iOS: apply the new virtual-tag hit-testing in
containsPointInView,wantsToHandleEventsAtPoint:, andgestureRecognizerShouldBegin. - Android: make
RNGestureHandlerDetectorViewimplementReactCompoundViewand addreactTagForTouch-based routing for virtual children.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/react-native-gesture-handler/apple/RNGestureHandler.mm | Adds recursive emitter-tag-based hit-testing for virtual detectors and uses it to gate handling/begin conditions. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt | Implements ReactCompoundView and adds touch→virtual-tag mapping logic for detector views. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
j-piasecki
approved these changes
May 13, 2026
InterceptingGestureDetector not recognizing gestures InterceptingGestureDetector not recognizing gestures
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
This PR fixes
VirtualGestureDetectorwithInterceptingGestureDetectorabove the content view. Virtual gestures work correctly in the following configuration:but they don't work in this one:
iOS
Added a generic recursive helper
isVirtualViewTag:touchedAtPoint:inView:that walks the view subtree at a given point and usestouchEventEmitterAtPoint:(fromRCTTouchableComponentViewProtocol) to check whether the virtual tag was hit. This replaces the previousRCTParagraphComponentView-specific check, making the mechanism work regardless of which view type contains the virtual content.Android
Note
Seems that
Androidchanges were unnecessary and were removed in 094cd23.RNGestureHandlerDetectorViewnow implementsReactCompoundViewand overridesreactTagForTouch. The orchestrator callsreactTagForTouchon anyReactCompoundViewit encounters during traversal and looks up handlers registered for the returned tag. Previously, whenInterceptingGestureDetectorsat between the outerGestureDetectorand the row containingVirtualGestureDetectorchildren, the orchestrator never discovered the virtual handlers.Test plan
Tested on the following code