Skip to content

Commit 0bbc5a3

Browse files
authored
[Android] Check the overflow ancestor pass against the detector child's bounds (#4605)
## Description Since #4532 a native detector's frame is widened to cover its transformed child. The orchestrator already checks the detector's own handlers against the child's transform-aware bounds when the child didn't consume the touch (`useChildBounds`), so a translated-away child doesn't stay tappable over the area it vacated. The overflow pass right below that check still used the host frame. In an open `ReanimatedSwipeable` the widened host spans the whole row, so a tap on the action panel passed the "pointer inside the view" test, `isViewOverflowingParent` was true and `extractAncestorHandlers` recorded the row's pan and the list's scroll handler before the traversal reached the panel. `ButtonViewGroup.shouldBeginWithRecordedHandlers` then cancelled the button's handler at record time, so `RectButton`, `Pressable` and `Touchable` inside the panel never pressed. Whether a given open row was affected depended on whether a layout pass had run since opening, which is why it looked random. The overflow pass now uses the same bounds as the handler check above it. For every view that isn't a single-child detector host nothing changes. For the host, a pointer over the vacated area skips the early ancestor recording; the ancestors still get recorded in the normal order as the traversal unwinds, since they contain the pointer themselves. Native touch delivery from #4532 is a shadow node change and isn't touched. Fixes the action buttons of `ReanimatedSwipeable` rows on Android (regression from #4532, not in 3.3.0). ## Test plan Android emulator, `expo-example`, Reanimated Swipeable: - Swipe a row open, press `Flag` / the Gmail row icon / `Archive`: the row closes and the press fires. Before: nothing. - Tap the open row's content: still closes. - Reduced #4529 check in the empty screen: an RN `Switch` inside a detector whose child is translated (static transform and Reanimated slide) still toggles, and a triple tap still reaches the detector's gesture. `yarn lint:android` passes.
1 parent dff741a commit 0bbc5a3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,12 @@ class GestureHandlerOrchestrator(
662662
}
663663

664664
// if the pointer is inside the view but it overflows its parent, handlers attached to the parent
665-
// might not have been extracted (pointer might be in a child, but may be outside parent)
666-
if (coords[0] in 0f..view.width.toFloat() &&
667-
coords[1] in 0f..view.height.toFloat() &&
665+
// might not have been extracted (pointer might be in a child, but may be outside parent).
666+
// Checked against the same bounds as the handlers above: a detector frame widened to cover a
667+
// transformed child overflows its parent, but a pointer in the area the child vacated is not
668+
// over its content and must not record the ancestors ahead of the views behind it.
669+
if (boundsX in 0f..boundsView.width.toFloat() &&
670+
boundsY in 0f..boundsView.height.toFloat() &&
668671
isViewOverflowingParent(view) &&
669672
extractAncestorHandlers(view, coords, pointerId, event)
670673
) {

0 commit comments

Comments
 (0)