react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Propagate layout direction to Android views

Open NickGerleman opened this issue 1 year ago • 2 comments

Summary: Right now we use layout direction determined by I18NManager to influence the root Yoga layout direction.

Individual views may have a different resolved layout direction (e.g. due to direction style prop), and even though we don't rely on Android layout props, Android components still need to inherit or know the right layout direction to still do correct drawing. Example of this was scollbar showing up on the left, instead of right in RTL, as soon as ScrollView knew it was in RTL.

This has potential to change a good amount of behavior, so this is under QE.

Changelog: [Android][Fixed] - Propagate layout direction to Android views

Changelog: [Internal]

Differential Revision: D57248417

NickGerleman avatar May 11 '24 20:05 NickGerleman

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

facebook-github-bot avatar May 11 '24 20:05 facebook-github-bot

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,558,988 +352
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 22,928,800 +38
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 3f17c8b5f04cd80517d7ba3943745f37dce7f5dd Branch: main

analysis-bot avatar May 11 '24 20:05 analysis-bot

Hello @NickGerleman, I have a quick question. Is this change intended to support the direction layout prop on Android as well?

Currently, the official documentation provides guidance on layout direction, but the fact that it is not supported on Android is only mentioned on the interface description page.

This seems to cause confusion for users: https://github.com/facebook/react-native/issues/41289

bang9 avatar Oct 25 '24 03:10 bang9

Oh, this wasn't updated, but the PR was merged a while back. But it is only enabled by default in 0.77 https://github.com/facebook/react-native/commit/6cf0cfb5a47a437b8a17b50b4c70460be15ee1cd

direction should propagate to layout in new arch Android more generally, but context-specific layout direction has some bugs with ScrollView, border rendering, switches not looking correct, etc before this change.

NickGerleman avatar Oct 25 '24 04:10 NickGerleman

@NickGerleman Thank you for the response. So it works on the new architecture! By any chance, are there any plans to backport it(direction support on android) to the old architecture?

bang9 avatar Oct 25 '24 05:10 bang9