From 9aeba7b6bd293bdc6e786fce8af1f75f8dbe0b24 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 28 Jun 2018 01:16:43 -0700 Subject: [PATCH] RN: Add Support for `overflow` on Android Summary: Adds support for the `overflow` style property on React Native for Android. This switches overflowing views to be visible by default with the ability to override this at the container level using `overflow: 'hidden'`. This is the same behavior as React Native on iOS. One major caveat to this solution is that it uses `setClipChildren` which does not extend the hit target to the overflow draw regions. While this is a pitfall, the current state of React Native on Android where `overflow` is hidden by default (which is the opposite of iOS) is also a huge pitfall. But I think this moves us in the right direction because where you *don't* need the touch behavior, you are now able to leverage overflow draws. Reviewed By: himabindugadupudi Differential Revision: D8666509 fbshipit-source-id: 5e98e658e16188414016260224caa696b4fbd390 --- .../src/main/java/com/facebook/react/uimanager/ViewProps.java | 4 ++-- .../java/com/facebook/react/views/view/ReactViewGroup.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java index f85236d4842dc1..15ea0c6d40ea0f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java @@ -254,8 +254,8 @@ public static boolean isLayoutOnly(ReadableMap map, String prop) { return map.isNull(BORDER_RIGHT_WIDTH) || map.getDouble(BORDER_RIGHT_WIDTH) == 0d; case BORDER_BOTTOM_WIDTH: return map.isNull(BORDER_BOTTOM_WIDTH) || map.getDouble(BORDER_BOTTOM_WIDTH) == 0d; - case OVERFLOW: // We do nothing with this right now. - return true; + case OVERFLOW: + return map.isNull(OVERFLOW) || map.getString(OVERFLOW) == "visible"; default: return false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index 1915b6eb48fb26..74b14bae8cc5e7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -112,6 +112,7 @@ public void onLayoutChange( public ReactViewGroup(Context context) { super(context); + setClipChildren(false); mDrawingOrderHelper = new ViewGroupDrawingOrderHelper(this); } @@ -638,6 +639,7 @@ public void setHitSlopRect(@Nullable Rect rect) { } public void setOverflow(String overflow) { + setClipChildren(mOverflow == "hidden"); mOverflow = overflow; invalidate(); }