Skip to content

Fall back to the layout direction for Text paragraph direction on Android - #60526

Open
lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/issue-60449-rtl-paragraph-direction
Open

lazerg wants to merge 2 commits into
react:mainfrom
lazerg:fix/issue-60449-rtl-paragraph-direction

Conversation

@lazerg

@lazerg lazerg commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

On Android, a Text in a right-to-left layout is laid out as a left-to-right paragraph when it has no strong character outside of Unicode isolates, for example '⁨Anna⁩ – ⁨Bob⁩' from a message formatter. It is aligned to the right but reads Anna – Bob instead of Bob – Anna.

TextLayoutManager built the StaticLayout (and checked BoringLayout) with the default FIRSTSTRONG_LTR heuristic, so text without a usable strong character always got a left-to-right paragraph. Now the whole text's first strong character decides, falling back to the layout direction when there is none, like a TextView with TEXT_DIRECTION_FIRST_STRONG in an RTL view. Paragraphs without a strong character (digits, emoji) follow that direction too, so they keep the same alignment as the rest of the text. Text with a strong character outside its isolates still takes its direction from that character. In an RTL layout this also means neutral-only text such as 1 – 2 reads right to left, as it does in a native TextView.

Fixes #60449

Changelog:

[ANDROID] [FIXED] - Text in a right-to-left layout without a leading strong character is laid out right to left

Test Plan:

Added TextLayoutManagerTextDirectionTest, which checks the paragraph direction of layouts for isolated-only, neutral-only and LTR-first (multi-line) text with RTL and LTR layout direction. The isolated and neutral RTL cases fail without the change. I didn't run the issue's reproducer on a device.

./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests "com.facebook.react.views.text*" --tests "com.facebook.react.views.textinput*"

@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

Visual regression

No visual differences at 2eaf3c83cf04.

ios: no capture

This branch has not been deployed

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

Labels

Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: a Text in a right-to-left layout is laid out left to right when all its strong characters are inside isolates

1 participant