Skip to content

Commit 65c2fa0

Browse files
committed
fix: ensure text aligns center regardless of RTL setting
1 parent 4dcdb7e commit 65c2fa0

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

packages/uikit-react-native-foundation/src/components/Text/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const Text = ({ children, color, style, supportRTLAlign = true, originalText, ..
3333
]) as TextStyle;
3434

3535
const textAlign = (() => {
36+
if (textStyle.textAlign === 'center') return 'center';
3637
if (I18nManager.isRTL && supportRTLAlign) {
3738
if (
3839
(originalText && isStartsWithRTL(originalText)) ||

packages/uikit-react-native-foundation/src/components/TextInput/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const TextInput = React.forwardRef<RNTextInput, Props>(function TextInput(
3434
]) as TextStyle;
3535

3636
const textAlign = (() => {
37+
if (textStyle.textAlign === 'center') return 'center';
3738
if (I18nManager.isRTL && supportRTLAlign) {
3839
const text = originalText || props.value || props.placeholder;
3940
// Note: TextInput is not affected by doLeftAndRightSwapInRTL
@@ -44,7 +45,7 @@ const TextInput = React.forwardRef<RNTextInput, Props>(function TextInput(
4445
}
4546
}
4647

47-
if (textStyle.textAlign) textStyle.textAlign;
48+
if (textStyle.textAlign) return textStyle.textAlign;
4849
return undefined;
4950
})();
5051

0 commit comments

Comments
 (0)