Skip to content

Commit da8ed6b

Browse files
JoshuaGrossfacebook-github-bot
authored andcommitted
Disable setRemoveClippedSubviews in ReactHorizontalScrollContainerView.java in RTL mode
Summary: setRemoveClippedSubviews in ReactHorizontalScrollContainerView.java in RTL mode is overzealous and unexpectedly clips out views in a way that is not desirable. It seems like what is actually happening is that the computed rect for the view is "0,0" and so contents are assumed to always be outside of this rect. For now I've disabled this feature. We can investigate as a followup. Changelog: [Android][Changed] Clipping subviews has been temporarily disabled in HorizontalScrollView in RTL mode. Minor/negligible perf impact. Reviewed By: sammy-SC Differential Revision: D26808937 fbshipit-source-id: 85af9c3fb542db9ca3aae03413a475695cd53391
1 parent 913c958 commit da8ed6b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollContainerView.java

+22
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,30 @@ public ReactHorizontalScrollContainerView(Context context) {
2727
mCurrentWidth = 0;
2828
}
2929

30+
@Override
31+
public void setRemoveClippedSubviews(boolean removeClippedSubviews) {
32+
// Clipping doesn't work well for horizontal scroll views in RTL mode - in both
33+
// Fabric and non-Fabric - especially with TextInputs. The behavior you could see
34+
// is TextInputs being blurred immediately after being focused. So, for now,
35+
// it's easier to just disable this for these specific RTL views.
36+
// TODO T86027499: support `setRemoveClippedSubviews` in RTL mode
37+
if (mLayoutDirection == LAYOUT_DIRECTION_RTL) {
38+
super.setRemoveClippedSubviews(false);
39+
return;
40+
}
41+
42+
super.setRemoveClippedSubviews(removeClippedSubviews);
43+
}
44+
3045
@Override
3146
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
47+
/**
48+
* Note: in RTL mode, *when layout width changes*, we adjust the scroll position. Practically,
49+
* this means that on the first (meaningful) layout we will go from position 0 to position
50+
* (right - screenWidth). In theory this means if the width of the view ever changes during
51+
* layout again, scrolling could jump. Which shouldn't happen in theory, but... if you find a
52+
* weird product bug that looks related, keep this in mind.
53+
*/
3254
if (mLayoutDirection == LAYOUT_DIRECTION_RTL) {
3355
// When the layout direction is RTL, we expect Yoga to give us a layout
3456
// that extends off the screen to the left so we re-center it with left=0

0 commit comments

Comments
 (0)