Skip to content

[Android] Fix Intercepting and Virtual detectors hit testing#4095

Merged
j-piasecki merged 1 commit into
mainfrom
copilot/check-intercepting-virtual-detectors
Apr 16, 2026
Merged

[Android] Fix Intercepting and Virtual detectors hit testing#4095
j-piasecki merged 1 commit into
mainfrom
copilot/check-intercepting-virtual-detectors

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

PR #3981 changed the hit-test condition in GestureHandler.handle() from view is RNGestureHandlerDetectorView to hostDetectorView != null, which is too broad — hostDetectorView is set for all handler types (regular, native, virtual, intercepting), but the detector-child coordinate transform should only run when the handler's view is the detector itself.

For Virtual/Intercepting handlers, the event is already in the virtual child's coordinate space. Entering the detector branch applies a bogus transform, breaking x/y and isWithinBounds.

Fix

Added view == detectorView to the condition so the multi-child hit test only runs when the handler is bound directly to the detector view:

// Before (broken): enters branch for all handlers with a hostDetectorView
if (detectorView != null && detectorView.isNotEmpty()) {

// After: only enters for handlers whose view IS the detector
if (detectorView != null && view == detectorView && detectorView.isNotEmpty()) {

PR #3981 changed the condition from `view is RNGestureHandlerDetectorView` to
`hostDetectorView != null`, which incorrectly caused Virtual and Intercepting
detector handlers to enter the detector-child coordinate transform branch.
These handlers have their events in the virtual child's coordinate space,
not the detector's. Adding `view == detectorView` restores correct behavior
while preserving the multi-child iteration logic.
Copilot AI review requested due to automatic review settings April 16, 2026 09:54
Copilot AI review requested due to automatic review settings April 16, 2026 09:54
@m-bert m-bert requested a review from j-piasecki April 16, 2026 09:55
Copilot AI requested a review from m-bert April 16, 2026 09:58
@m-bert m-bert marked this pull request as ready for review April 16, 2026 09:58
Copilot AI review requested due to automatic review settings April 16, 2026 09:58
@m-bert m-bert changed the title Fix Intercepting and Virtual detector hit testing on Android [Android] Fix Intercepting and Virtual detectors hit testing Apr 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refines Android hit-testing in GestureHandler.handle() so the detector-child coordinate transform only runs when the handler is attached directly to the RNGestureHandlerDetectorView, fixing incorrect x/y and bounds checks for virtual (and related) detector-attached handlers.

Changes:

  • Tightens the multi-child detector hit-test condition by requiring view == detectorView.
  • Prevents applying an extra (incorrect) detector→child coordinate transform for handlers whose events are already in the child’s coordinate space.

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

@j-piasecki j-piasecki merged commit 59983a5 into main Apr 16, 2026
8 checks passed
@j-piasecki j-piasecki deleted the copilot/check-intercepting-virtual-detectors branch April 16, 2026 13:18
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.

4 participants