Skip to content

Commit

Permalink
Disable setRemoveClippedSubviews in ReactHorizontalScrollContainerVie…
Browse files Browse the repository at this point in the history
…w.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
  • Loading branch information
JoshuaGross authored and facebook-github-bot committed Mar 4, 2021
1 parent 913c958 commit da8ed6b
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da8ed6b

Please sign in to comment.