diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java index 15aa7bfb7acdf7..0445fbdf36cf4a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java @@ -27,8 +27,30 @@ public ReactHorizontalScrollContainerView(Context context) { mCurrentWidth = 0; } + @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 (mLayoutDirection == LAYOUT_DIRECTION_RTL) { + super.setRemoveClippedSubviews(false); + return; + } + + super.setRemoveClippedSubviews(removeClippedSubviews); + } + @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { + /** + * Note: in RTL mode, *when layout width changes*, we adjust the scroll position. Practically, + * this means that on the first (meaningful) layout we will go from position 0 to position + * (right - screenWidth). In theory this means if the width of the view ever changes during + * layout again, scrolling could jump. Which shouldn't happen in theory, but... if you find a + * weird product bug that looks related, keep this in mind. + */ if (mLayoutDirection == LAYOUT_DIRECTION_RTL) { // When the layout direction is RTL, we expect Yoga to give us a layout // that extends off the screen to the left so we re-center it with left=0