From 9c71952f20cd831aa36dbe59e7b2a48794a8e108 Mon Sep 17 00:00:00 2001 From: Jiaqi Wu Date: Thu, 19 Jul 2018 17:41:41 -0700 Subject: [PATCH] Fix overflow issue in root view Summary: Set clipChildren to false by default in ReactRootView.java so that Overflow: visible/hidden will work for the root view. Moved sDefaultOverflowHidden from ReactViewGroup.java to ViewProps.java so that it can be used in both ReactViewGroup.java and ReactRootView.java. Reviewed By: mdvacca Differential Revision: D8727140 fbshipit-source-id: b593bed63e479cdbd22e4a025b936e6aeb28fc8c --- .../main/java/com/facebook/react/ReactRootView.java | 10 ++++++++++ .../java/com/facebook/react/uimanager/ViewProps.java | 5 +++++ .../com/facebook/react/views/view/ReactViewGroup.java | 7 +------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 6e8a92f60..13ed88113 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -48,6 +48,7 @@ import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.RootView; import com.facebook.react.uimanager.UIManagerHelper; import com.facebook.react.uimanager.UIManagerModule; +import com.facebook.react.uimanager.ViewProps; import com.facebook.react.uimanager.common.MeasureSpecProvider; import com.facebook.react.uimanager.common.SizeMonitoringFrameLayout; import com.facebook.react.uimanager.common.UIManagerType; @@ -97,14 +98,23 @@ public class ReactRootView extends SizeMonitoringFrameLayout public ReactRootView(Context context) { super(context); + init(); } public ReactRootView(Context context, AttributeSet attrs) { super(context, attrs); + init(); } public ReactRootView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + init(); + } + + private void init() { + if (!ViewProps.sDefaultOverflowHidden) { + setClipChildren(false); + } } @Override 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 58e67ccb7..3ad6f640d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewProps.java @@ -17,6 +17,11 @@ import java.util.HashSet; */ public class ViewProps { + /** + * Kill switch to make overflow hidden by default. This flag will eventually be removed. + */ + public static boolean sDefaultOverflowHidden; + public static final String VIEW_CLASS_NAME = "RCTView"; // Layout only (only affect positions of children, causes no drawing) 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 e8afaa935..ce2fa9528 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 @@ -49,11 +49,6 @@ public class ReactViewGroup extends ViewGroup implements ReactInterceptingViewGroup, ReactClippingViewGroup, ReactPointerEventsView, ReactHitSlopView, ReactZIndexedViewGroup { - /** - * Kill switch to make overflow hidden by default. This flag will eventually be removed. - */ - public static boolean sDefaultOverflowHidden; - private static final int ARRAY_CAPACITY_INCREMENT = 12; private static final int DEFAULT_BACKGROUND_COLOR = Color.TRANSPARENT; private static final LayoutParams sDefaultLayoutParam = new ViewGroup.LayoutParams(0, 0); @@ -119,7 +114,7 @@ public class ReactViewGroup extends ViewGroup implements public ReactViewGroup(Context context) { super(context); // TODO: Remove this check after a couple public releases. - if (!sDefaultOverflowHidden) { + if (!ViewProps.sDefaultOverflowHidden) { setClipChildren(false); } mDrawingOrderHelper = new ViewGroupDrawingOrderHelper(this);