Forced RTL in Brownfield Apps Due to android:supportsRtl="true"
Requirement in React Native 0.75+
#50500
Labels
Needs: Attention
Issues where the author has responded to feedback.
Platform: Android
Android applications.
Type: Unsupported Version
Issues reported to a version of React Native that is no longer supported
Description
In React Native 0.75, a breaking change requires
android:supportsRtl="true"
in the Android manifest. This change causes issues for brownfield applications that integrate React Native into an existing Android app with a mix of LTR and RTL layouts.Our application consists of:
Before React Native 0.75, the RTL configuration worked as expected. However, since this change:
android:supportsRtl="false"
is set (or omitted), React Native incorrectly lays out some components in LTR instead of RTL.android:supportsRtl="true"
is set, the entire app (including old native XML screens) is forced into RTL, which breaks the native LTR layouts.This behavior only occurs when the device language is set to an RTL language (e.g.,
he-IL
). The issue happens because whenandroid:supportsRtl="true"
, the direction ofLinearLayout
and other native views is automatically set to RTL based on the device locale.Code Reference
The issue appears to be caused by the following logic in
I18nUtil.kt
:in this commit
82c6f8a
this PR
#44538
📂 Path:
packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/i18nmanager/I18nUtil.kt
While this code is not part of Yoga, Yoga may be observing this behavior, leading to the layout inconsistencies.
Expected Behavior
There should be a way to enable RTL only for React Native screens while keeping old native screens unchanged.
Actual Behavior
React Native forces either:
android:supportsRtl="false"
, which is incorrect.android:supportsRtl="true"
, which breaks old native LTR screens.Possible Solutions
android:supportsRtl="true"
.Steps to reproduce
install app
React Native Version
0.78.0
Affected Platforms
Runtime - Android
Output of
npx @react-native-community/cli info
Stacktrace or Logs
Reproducer
https://github.com/YOEL311/reproduceRN-RTL
Screenshots and Videos
No response
The text was updated successfully, but these errors were encountered: