From cb5302e2bc84ece6f55dc06deb56c10034c5dfea Mon Sep 17 00:00:00 2001 From: Mathieu Acthernoene Date: Wed, 22 Jul 2026 14:20:56 +0200 Subject: [PATCH] fix(ios): align text to the right by default in RTL --- .../textlayoutmanager/RCTAttributedTextUtils.mm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm index 9e1b3e6dde8..3f55678f65c 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm @@ -18,10 +18,11 @@ using namespace facebook::react; -inline static TextAlignment RCTResolveTextAlignment(TextAlignment textAlignment, LayoutDirection layoutDirection) +inline static TextAlignment RCTResolveTextAlignment(TextAlignment textAlignment, bool isRTL) { - const bool isRTL = layoutDirection == LayoutDirection::RightToLeft; switch (textAlignment) { + case TextAlignment::Natural: + return isRTL ? TextAlignment::Right : TextAlignment::Left; case TextAlignment::Start: return isRTL ? TextAlignment::Right : TextAlignment::Left; case TextAlignment::End: @@ -212,10 +213,10 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex // Paragraph Style NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; BOOL isParagraphStyleUsed = NO; - if (textAttributes.alignment.has_value()) { - TextAlignment textAlignment = RCTResolveTextAlignment( - textAttributes.alignment.value_or(TextAlignment::Natural), - textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight)); + const bool isRTL = textAttributes.layoutDirection == LayoutDirection::RightToLeft; + if (textAttributes.alignment.has_value() || isRTL) { + TextAlignment textAlignment = + RCTResolveTextAlignment(textAttributes.alignment.value_or(TextAlignment::Natural), isRTL); paragraphStyle.alignment = RCTNSTextAlignmentFromTextAlignment(textAlignment); isParagraphStyleUsed = YES;