Repository navigation
Align text to the left by default in LTR on iOS - #59004
Open
YevheniiKotyrlo wants to merge 1 commit into
Open
YevheniiKotyrlo wants to merge 1 commit into
YevheniiKotyrlo wants to merge 1 commit into
Conversation
A paragraph that declares no textAlign gets an explicit alignment on iOS only when its layout direction is right to left (react#57634). In a left-to-right layout the paragraph style keeps NSTextAlignmentNatural, which UIKit resolves against the app's localization rather than the paragraph, so in an app running in a right-to-left language a left-to-right subtree is drawn flush right while Android draws it flush left. Resolve the alignment whenever the paragraph's layout direction is known, which is what RCTIsParagraphStyleEffectivelySame already assumes when it compares paragraph styles.
Contributor
Author
YevheniiKotyrlo
marked this pull request as ready for review
October 12, 2026 05:05
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary:
Follow-up to #57634. A
<Text>that declares notextAlignnow aligns to the right in an RTL layout on iOS, but in an LTR layout its paragraph style still carriesNSTextAlignmentNatural, which UIKit resolves against the app's localization rather than the paragraph (NSTextAlignment.natural: "the default alignment associated with the current localization of the app"). So when the app runs in a right-to-left language, text in an LTR subtree, such as adirection: 'ltr'view, is drawn flush right on iOS and flush left on Android.RCTNSTextAttributesFromTextAttributesnow resolves the alignment whenever the paragraph's layout direction is known, not only when it is RTL, so an undeclared alignment follows the start of the layout direction in both directions.RCTIsParagraphStyleEffectivelySamealready compares a natural alignment as the start of the layout direction, so the drawn alignment now matches what it assumes. Text inputs are unaffected: their text attributes carry no layout direction, so aUITextFieldkeeps aligning to its own view.Changelog:
[IOS] [FIXED] - Align text to the left by default in LTR when
textAlignis not set, whatever the app's languageTest Plan:
RCTAttributedTextUtilsTest:testUndeclaredTextAlignmentResolvesWithLayoutDirectionfails onmain(an LTR paragraph gets no paragraph style) and passes with the change;testUndeclaredTextAlignmentWithoutLayoutDirectionStaysNaturalpasses on both.React-RCTFabric'sTestsspec passes on an iOS 18.0 simulator, 56 tests with 0 failures, run with:testspecs => ['Tests']andRCTParagraphComponentViewTests.mmexcluded because it does not compile under CocoaPods.direction: 'ltr', its initial state) on an iPhone 16 simulator, iOS 18.0, launched with Xcode's right-to-left pseudolanguage (-AppleTextDirection YES -NSForceRightToLeftWritingDirection YES), before and after: the pair. Only the twoauto (default)lines move, from flush right to flush left; theleft,center,rightandjustifylines are pixel-identical.node scripts/clang-format.js --checkpasses.