Skip to content

Commit 59983a5

Browse files
authored
[Android] Fix Intercepting and Virtual detectors hit testing (#4095)
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: ```kotlin // 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()) { ``` Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 1697b39 commit 59983a5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core

packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ open class GestureHandler {
391391
// in the coordinate system of the child view, but I'm not sure of the
392392
// consequences
393393
val detectorView = hostDetectorView
394-
if (detectorView != null && detectorView.isNotEmpty()) {
394+
if (detectorView != null && view == detectorView && detectorView.isNotEmpty()) {
395395
val outPoint = PointF()
396396
var foundChild = false
397397

0 commit comments

Comments
 (0)