diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index fa65841b75a..20304f28f1c 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -6646,6 +6646,7 @@ public class com/facebook/react/views/scroll/ReactHorizontalScrollContainerView public fun (Landroid/content/Context;)V public fun getLayoutDirection ()I protected fun onLayout (ZIIII)V + public fun setRemoveClippedSubviews (Z)V } public final class com/facebook/react/views/scroll/ReactHorizontalScrollContainerViewManager : com/facebook/react/views/view/ReactClippingViewManager { @@ -7933,6 +7934,7 @@ public class com/facebook/react/views/view/ReactViewGroup : android/view/ViewGro public fun onInterceptTouchEvent (Landroid/view/MotionEvent;)Z protected fun onLayout (ZIIII)V protected fun onMeasure (II)V + protected fun onSizeChanged (IIII)V public fun onTouchEvent (Landroid/view/MotionEvent;)Z public fun removeView (Landroid/view/View;)V public fun removeViewAt (I)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java index 76e0c1c8ce3..fbb10ecfc40 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java @@ -36,6 +36,21 @@ public class ReactHorizontalScrollContainerView extends ReactViewGroup { return mLayoutDirection; } + @Override + public void setRemoveClippedSubviews(boolean removeClippedSubviews) { + // Clipping doesn't work well for horizontal scroll views in RTL mode - in both + // Fabric and non-Fabric - especially with TextInputs. The behavior you could see + // is TextInputs being blurred immediately after being focused. So, for now, + // it's easier to just disable this for these specific RTL views. + // TODO T86027499: support `setRemoveClippedSubviews` in RTL mode + if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { + super.setRemoveClippedSubviews(false); + return; + } + + super.setRemoveClippedSubviews(removeClippedSubviews); + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { 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 263b765d8ca..b50a6257b25 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 @@ -195,12 +195,7 @@ public class ReactViewGroup extends ViewGroup @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - // If the size or position of the view has changed it may intersect different children than - // before. If "removeClippedSubviews" is set, we must re-evaluate intersection to render newly - // visible children, and remove those no longer visible. - if (changed && mRemoveClippedSubviews) { - updateClippingRect(); - } + // No-op since UIManagerModule handles actually laying out children. } @Override @@ -487,6 +482,14 @@ public class ReactViewGroup extends ViewGroup return super.getChildVisibleRect(child, r, offset); } + @Override + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + super.onSizeChanged(w, h, oldw, oldh); + if (mRemoveClippedSubviews) { + updateClippingRect(); + } + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow();