Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/TextInput/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export const getFilledTextInputData = (
flex: 1,
color: onSurface,
fontSize: INPUT_FONT_SIZE,
textAlign: hasSuffix === shared.isRTL ? 'left' : 'right',
textAlign: shared.isRTL ? 'right' : 'left',
writingDirection: shared.isRTL ? 'rtl' : 'ltr',
},
textInputProps.multiline && {
Expand Down Expand Up @@ -538,7 +538,7 @@ export const getOutlinedTextInputData = (
flex: 1,
color: onSurface,
fontSize: INPUT_FONT_SIZE,
textAlign: hasSuffix === shared.isRTL ? 'left' : 'right',
textAlign: shared.isRTL ? 'right' : 'left',
writingDirection: shared.isRTL ? 'rtl' : 'ltr',
},
textInputProps.multiline && {
Expand Down
10 changes: 6 additions & 4 deletions src/components/__tests__/TextInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1552,38 +1552,40 @@ it('places prefix Text before the TextInput and suffix Text after it', async ()
);
});

it('aligns input text toward the suffix when suffix is active (LTR)', async () => {
it('start-aligns input text even when suffix is active (LTR)', async () => {
await render(
<TextInput
label="Label"
value="5"
onChangeText={() => {}}
prefix="$"
suffix="/100"
testID="tf-suffix-align-ltr"
/>
);

expect(screen.getByTestId('tf-suffix-align-ltr')).toHaveStyle({
textAlign: 'right',
textAlign: 'left',
writingDirection: 'ltr',
});
});

it('aligns input text toward the suffix when suffix is active (RTL)', async () => {
it('start-aligns input text even when suffix is active (RTL)', async () => {
I18nManager.isRTL = true;

await render(
<TextInput
label="Label"
value="5"
onChangeText={() => {}}
prefix="$"
suffix="/100"
testID="tf-suffix-align-rtl"
/>
);

expect(screen.getByTestId('tf-suffix-align-rtl')).toHaveStyle({
textAlign: 'left',
textAlign: 'right',
writingDirection: 'rtl',
});
});
Expand Down
Loading