Skip to content

Commit 51fe190

Browse files
ryancatfacebook-github-bot
authored andcommitted
Do not register touch target for out of bounds events with clipChildren set to true
Summary: Similar to the previous diff, we should not allow view group that has clipChildren set to true to respond events that are out of bounds. Changelog: [Internal][Android] Reviewed By: ShikaSD Differential Revision: D33102331 fbshipit-source-id: de3a5ffdd5293ada1d2c211659e79edc697b5d15
1 parent 0bd09c0 commit 51fe190

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,24 @@ private static View findTouchTargetView(
178178
// We prefer returning a child, so we check for a child that can handle the touch first
179179
if (allowReturnTouchTargetTypes.contains(TouchTargetReturnType.CHILD)
180180
&& view instanceof ViewGroup) {
181-
// We don't allow touches on views that are outside the bounds of an `overflow: hidden` and
182-
// `overflow: scroll` View.
183-
if (view instanceof ReactOverflowView) {
184-
@Nullable String overflow = ((ReactOverflowView) view).getOverflow();
185-
if ((ViewProps.HIDDEN.equals(overflow) || ViewProps.SCROLL.equals(overflow))
186-
&& !isTouchPointInView(eventCoords[0], eventCoords[1], view)) {
181+
ViewGroup viewGroup = (ViewGroup) view;
182+
if (!isTouchPointInView(eventCoords[0], eventCoords[1], view)) {
183+
// We don't allow touches on views that are outside the bounds of an `overflow: hidden` and
184+
// `overflow: scroll` View.
185+
if (view instanceof ReactOverflowView) {
186+
@Nullable String overflow = ((ReactOverflowView) view).getOverflow();
187+
if (ViewProps.HIDDEN.equals(overflow) || ViewProps.SCROLL.equals(overflow)) {
188+
return null;
189+
}
190+
}
191+
192+
// We don't allow touches on views that are outside the bounds and has clipChildren set to
193+
// true.
194+
if (viewGroup.getClipChildren()) {
187195
return null;
188196
}
189197
}
190198

191-
ViewGroup viewGroup = (ViewGroup) view;
192199
int childrenCount = viewGroup.getChildCount();
193200
// Consider z-index when determining the touch target.
194201
ReactZIndexedViewGroup zIndexedViewGroup =

0 commit comments

Comments
 (0)