Skip to content

Commit 0474edd

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

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

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

3535
const textAlign = (() => {
36+
if (textStyle.textAlign && textStyle.textAlign !== 'left' && textStyle.textAlign !== 'right') {
37+
return textStyle.textAlign;
38+
}
39+
3640
if (I18nManager.isRTL && supportRTLAlign) {
3741
if (
3842
(originalText && isStartsWithRTL(originalText)) ||
@@ -43,6 +47,7 @@ const Text = ({ children, color, style, supportRTLAlign = true, originalText, ..
4347
return I18nManager.doLeftAndRightSwapInRTL ? 'right' : 'left';
4448
}
4549
}
50+
4651
if (textStyle.textAlign) return textStyle.textAlign;
4752
return undefined;
4853
})();

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

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

3636
const textAlign = (() => {
37+
if (textStyle.textAlign && textStyle.textAlign !== 'left' && textStyle.textAlign !== 'right') {
38+
return textStyle.textAlign;
39+
}
40+
3741
if (I18nManager.isRTL && supportRTLAlign) {
3842
const text = originalText || props.value || props.placeholder;
3943
// Note: TextInput is not affected by doLeftAndRightSwapInRTL
@@ -44,7 +48,7 @@ const TextInput = React.forwardRef<RNTextInput, Props>(function TextInput(
4448
}
4549
}
4650

47-
if (textStyle.textAlign) textStyle.textAlign;
51+
if (textStyle.textAlign) return textStyle.textAlign;
4852
return undefined;
4953
})();
5054

0 commit comments

Comments
 (0)