From 8618eecde6e5858a501f8d0924379c1c96802dad Mon Sep 17 00:00:00 2001 From: Jorge Cabiedes Acosta Date: Wed, 28 Aug 2024 11:58:42 -0700 Subject: [PATCH] Make Filters implicitly set overflow hidden (#46145) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46145 Filters clip children by default due to using `RenderEffect` we are keeping this behavior but we were clipping to the border box while Web clips to padding box. To keep the clipping consistent we are enforcing `Overflow.HIDDEN` when a view contains a filter. Changelog: [Internal] Reviewed By: joevilches Differential Revision: D61630698 fbshipit-source-id: dcc3fd680546793096d8996f405724df0a834079 --- .../com/facebook/react/views/view/ReactViewGroup.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index d05fba51a0c167..bebb92ee8ad4e7 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -969,7 +969,7 @@ && needsIsolatedLayer()) { @Override protected void dispatchDraw(Canvas canvas) { if (ReactNativeFeatureFlags.enableBackgroundStyleApplicator()) { - if (mOverflow != Overflow.VISIBLE) { + if (mOverflow != Overflow.VISIBLE || getTag(R.id.filter) != null) { BackgroundStyleApplicator.clipToPaddingBox(this, canvas); } super.dispatchDraw(canvas); @@ -1034,7 +1034,14 @@ protected boolean drawChild(Canvas canvas, View child, long drawingTime) { } private void dispatchOverflowDraw(Canvas canvas) { - switch (mOverflow) { + Overflow tempOverflow = mOverflow; + + // If the view contains a filter, we clip to the padding box. + if (getTag(R.id.filter) != null) { + tempOverflow = Overflow.HIDDEN; + } + + switch (tempOverflow) { case VISIBLE: if (mPath != null) { mPath.rewind();