Skip to content

Fix Android removeClippedSubviews in horizontal ScrollView in RTL#45356

Closed
NickGerleman wants to merge 1 commit into
facebook:mainfrom
NickGerleman:export-D59566611
Closed

Fix Android removeClippedSubviews in horizontal ScrollView in RTL#45356
NickGerleman wants to merge 1 commit into
facebook:mainfrom
NickGerleman:export-D59566611

Conversation

@NickGerleman
Copy link
Copy Markdown
Contributor

Summary:
Subview clipping was disabled for RTL on Android due to a bug where TextInputs automatically blur when selected. This bug is reintroduced when set_android_layout_direction is set.

When set_android_layout_direction is enabled, and we use View getLayoutDirection() instead of I18nManager.isRTL(), the layout direction is not known until mounting time. This defeats the check a setRemoveClippedSubviews() prop setter to ignore the prop if the view is RTL (since it doesn't invalidate when a new layout direction is set).

The root cause of the underlying RTL bug is due to updating clipping status triggered by onSizeChanged(), which is called before onLayout(), where ReactHorizontalScrollContainerView offsets content in RTL. This also seems potentially erroneous, as we do not update the clipping rect on position change (unless that is handled elsewhere).

I moved the check to onLayout(), called after ReactHorizontalScrollView will change metrics, which seems to fix the issue. I then removed the exclusion in removeClippedSubviews prop setter.

Changelog:
[Android][Fixed] - Fix Android removeClippedSubviews in RTL

Differential Revision: D59566611

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jul 10, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D59566611

…cebook#45356)

Summary:
Pull Request resolved: facebook#45356

Subview clipping was disabled for RTL on Android due to a bug where TextInputs automatically blur when selected. This bug is reintroduced when `set_android_layout_direction` is set.

When `set_android_layout_direction` is enabled, and we use View `getLayoutDirection()` instead of `I18nManager.isRTL()`, the layout direction is not known until mounting time. This defeats the check a `setRemoveClippedSubviews()` prop setter to ignore the prop if the view is RTL (since it doesn't invalidate when a new layout direction is set).

The root cause of the underlying RTL bug is due to updating clipping status triggered by `onSizeChanged()`, which is called before `onLayout()`, where `ReactHorizontalScrollContainerView` offsets content in RTL. This also seems potentially erroneous, as we do not update the clipping rect on position change (unless that is handled elsewhere).

I moved the check to `onLayout()`, called after ReactHorizontalScrollView will change metrics, which seems to fix the issue. I then removed the exclusion in `removeClippedSubviews` prop setter.

Changelog:
[Android][Fixed] - Fix Android removeClippedSubviews in RTL

Differential Revision: D59566611
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D59566611

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jul 11, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in ea6928f.

@github-actions
Copy link
Copy Markdown

This pull request was successfully merged by @NickGerleman in ea6928f.

When will my fix make it into a release? | How to file a pick request?

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been reverted by d68a177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner Reverted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants