diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java index bf9a6207c77..2fdbe18d643 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java @@ -178,6 +178,16 @@ public class TouchTargetHelper { // We prefer returning a child, so we check for a child that can handle the touch first if (allowReturnTouchTargetTypes.contains(TouchTargetReturnType.CHILD) && view instanceof ViewGroup) { + // We don't allow touches on views that are outside the bounds of an `overflow: hidden` and + // `overflow: scroll` View. + if (view instanceof ReactOverflowView) { + @Nullable String overflow = ((ReactOverflowView) view).getOverflow(); + if ((ViewProps.HIDDEN.equals(overflow) || ViewProps.SCROLL.equals(overflow)) + && !isTouchPointInView(eventCoords[0], eventCoords[1], view)) { + return null; + } + } + ViewGroup viewGroup = (ViewGroup) view; int childrenCount = viewGroup.getChildCount(); // Consider z-index when determining the touch target. @@ -198,22 +208,7 @@ public class TouchTargetHelper { eventCoords[1] = childPoint.y; View targetView = findTouchTargetViewWithPointerEvents(eventCoords, child, pathAccumulator); if (targetView != null) { - // We don't allow touches on views that are outside the bounds of an `overflow: hidden` - // View - boolean inOverflowBounds = true; - if (viewGroup instanceof ReactOverflowView) { - @Nullable String overflow = ((ReactOverflowView) viewGroup).getOverflow(); - if ((ViewProps.HIDDEN.equals(overflow) || ViewProps.SCROLL.equals(overflow)) - && !isTouchPointInView(restoreX, restoreY, view)) { - inOverflowBounds = false; - } - } - if (inOverflowBounds) { - return targetView; - } else if (pathAccumulator != null) { - // Not a hit, reset the path found so far - pathAccumulator.clear(); - } + return targetView; } eventCoords[0] = restoreX; eventCoords[1] = restoreY;