Skip to content

RTL guide: LocaleProvider on a subtree doesn't mirror its layout #5243

Done

Description

@Doberjohn

What the guide says

"Overriding direction for a subtree" in docs/6.x/docs/guides/rtl.md wraps part of the app in <LocaleProvider direction="rtl"> and says the components inside "will use RTL layout".

What happens

LocaleProvider only sets the direction Paper's components read with useLocale(). It renders no View and sets no direction style or dir, so nothing tells the layout engine to mirror:

  • On iOS and Android, rows follow I18nManager for the whole app. In an LTR app, a TextInput inside an RTL LocaleProvider keeps its startAccessory on the left while its text aligns to the right.
  • On web, React Native Web takes the direction from a dir prop on one of its Views, and the browser from <html dir>, so the rows stay LTR there too.

This is from reading the code; I haven't checked it on a device. The note under "How it works" already says a direction that doesn't match the app's can give a wrong layout, so the subtree example contradicts it.

Suggested fix

Reword the section to say that LocaleProvider changes what Paper treats as the writing direction (text alignment, which icons mirror, which side some parts take), not the layout direction. To mirror a subtree as well:

  • on web, also wrap it in a View with dir="rtl";
  • on iOS, React Native's direction: 'rtl' style on a wrapping View sets the layout direction;
  • on Android, React Native documents that style as iOS-only, so the guide should say a mixed-direction screen isn't supported there.

#5221 adds a caution to the same guide that <View dir="rtl"> isn't supported on web, so the two should agree before either lands.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions