Skip to content
Open
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
9 changes: 7 additions & 2 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,15 +527,20 @@ function TextInput({
</View>

<View style={styles.addendum}>
{!!supportingText && (
{supportingText ? (
<Text
key={hasError ? 'error' : 'supporting'}
{...accessibilityProps.supportingText}
style={supportingTextStyles}
>
{supportingText}
</Text>
)}
) : hasCounter ? (
<View
testID="text-input-addendum-spacer"
style={styles.addendumSpacer}
/>
) : null}
Comment on lines +538 to +543

@apex-sentinel-staging apex-sentinel-staging Bot Nov 20, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 348793c: marked fixed by kachmashk in this comment; the code it pointed at changed.

🆕 🟡 Minor · New test for the counter-without-supporting-text spacer cannot fail without the change

The new it('renders the counter without supporting text') passes on pre-change code because the counter Text was already always rendered by {hasCounter && ...} (TextInput.tsx:542), so toBeOnTheScreen says nothing about the new addendumSpacer branch at TextInput.tsx:538-540. Deleting that branch leaves the whole suite green.

Suggested change

Give the spacer a testID and assert it is rendered as a sibling before the counter inside the addendum (or assert the counter's resolved position), so the test fails when the spacer branch is removed.

Details

Also raised here

Also raised at this location by persona senior-developer: Counter-only spacer fix is asserted by a test that passes without it — The new test renders the counter without supporting text (src/components/tests/TextInput.test.tsx:1471) only asserts expect(screen.getByText('2/10', includeHiddenElements)).toBeOnTheScreen(). The counter Text is rendered unconditionally by the hasCounter && (...) branch in TextInput.tsx:542 and is already asserted this way on native at lines 969 and 983, so the new test passes identically with the addendumSpacer View and the supportingText ? ... : hasCounter ? ... rewrite removed — nothing in the suite covers the positioning the PR added the spacer for (that the counter lands on the end side when there is no supporting text to carry flex: 1).

Also raised at this location by persona react-native-paper: Counter-without-supporting-text fix is asserted by a test that passed before the change — On web RTL the only visible effect of the spacer is the counter's horizontal position, and the test renders with no dir and asserts existence only, so nothing in the checkout fails if the : hasCounter ? <View style={styles.addendumSpacer} /> : null branch is deleted. The added test therefore does not cover the change it names (PR bullet: "A counter with no supporting text is now pushed to the end side through a flexible spacer").

persona: react-native-paper, senior-developer

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/like

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. It helps us make these findings more useful.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


{hasCounter && (
<Text {...accessibilityProps.counter} style={counterStyles}>
Expand Down
11 changes: 11 additions & 0 deletions src/components/TextInput/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export const styles = StyleSheet.create({
opacity: 0,
pointerEvents: 'none',
},
addendumSpacer: {
flex: 1,
},
supportingText: {
flex: 1,
marginTop: SUPPORTING_TEXT_MARGIN_TOP,
Expand Down Expand Up @@ -72,6 +75,14 @@ export const styles = StyleSheet.create({
alignItems: 'center',
marginStart: TEXT_INPUT_ACCESSORY_MARGIN_HORIZONTAL,
},
leadingAccessoryRTL: {
marginStart: 0,
marginRight: TEXT_INPUT_ACCESSORY_MARGIN_HORIZONTAL,
},
trailingAccessoryRTL: {
marginEnd: 0,
marginLeft: TEXT_INPUT_ACCESSORY_MARGIN_HORIZONTAL,
},
disabled: {
opacity: tokens.md.sys.state.opacity.disabled,
},
Expand Down
6 changes: 6 additions & 0 deletions src/components/TextInput/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export const getSharedTextInputStyleData = (
styles.supportingText,

@apex-sentinel-staging apex-sentinel-staging Bot Nov 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 6400150: the code it pointed at changed.

🟡 Minor · RTL-only web styles and logical start/end label offset run on no real web target

The label wrapper now gets { start: 52 } on every platform, and native LTR/RTL labels lose their left offset. The Jest preset is @react-native/jest-preset (ios), so the jest.replaceProperty(Platform, 'OS', 'web') tests exercise styles on a renderer that is not react-native-web, and getLabelWrapperStyle assertions only prove a start/end key exists, not that the platform honors it.

Suggested change

Verify the web output in a browser build (the docs/example app with dir="rtl") and, ideally, cover the web path with a Jest project that resolves react-native-web.

Details

Also raised here

Also raised at this location by persona javascript: New web-only RTL styles are only asserted under the native jest renderer — The two new style sheets exist only for Platform.OS === 'web', i.e. for the react-native-web renderer, yet every assertion that exercises them lives in src/components/tests/TextInput.test.tsx, which runs under the default @​react-native/jest-preset where Platform.OS is 'ios' and is only made to look like web with jest.replaceProperty(Platform, 'OS', 'web'). That replaces one constant, not the renderer, so the tests observe the style array the code produced rather than the CSS react-native-web emits — the only real risk these branches carry (whether inset-inline-start/end and the marginStart: 0, marginEnd: 12 flip are actually honoured by RNW) is covered by no executable check in CI.

persona: senior-developer, javascript

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apex-sentinel-staging like

Fixed: Web-only branches never ran in Jest, assertions only checked that keys existed or used the LTR/native value and missleading test names.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. It helps us make these findings more useful.

{
color: supportingTextColor,
textAlign: isRTL && Platform.OS === 'web' ? 'right' : 'left',
writingDirection: isRTL ? 'rtl' : 'ltr',
},
isDisabled && styles.disabled,
Expand All @@ -252,6 +253,7 @@ export const getSharedTextInputStyleData = (
styles.counter,
{
color: supportingTextColor,
textAlign: isRTL && Platform.OS === 'web' ? 'left' : 'right',
writingDirection: isRTL ? 'rtl' : 'ltr',
},
isDisabled && styles.disabled,
Expand All @@ -263,6 +265,7 @@ export const getSharedTextInputStyleData = (
fontSize: INPUT_FONT_SIZE,

@apex-sentinel-staging apex-sentinel-staging Bot Nov 20, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 348793c.

🆕 🟡 Minor · prefix/suffix now get writingDirection on native too, outside the PR's web-only scope

On native with I18nManager.forceRTL(true), prefix="$" now renders with writingDirection: 'rtl', changing glyph ordering of LTR affix strings. The style array is built once for all platforms and only the accessory-margin and textAlign branches are gated on Platform.OS === 'web'; these two lines are not.

⚠️ Check this patch before you commit it: the review doubted it would be right as written.

Suggested change

  const prefixStyles: StyleProp<TextStyle> = [
    styles.input,
    {
      fontSize: INPUT_FONT_SIZE,
      color: onSurfaceVariant,
      paddingEnd: PREFIX_END_PADDING,
      ...(Platform.OS === 'web' && { writingDirection: isRTL ? 'rtl' : 'ltr' }),
    },
    isDisabled && styles.disabled,
  ];
Details

Also raised here

Also raised at this location by persona react-native-paper: Platform-gated RTL styles and new prefix/suffix writingDirection have no native-side test — The web-only behaviours added in this diff are pinned only by the describe('on web in RTL') block, and none of the native tests asserts the opposite value, so the platform split the PR relies on is unprotected: removing Platform.OS === 'web' from the supporting-text/counter textAlign lines (utils.ts:246, 256) or from the accessory guards (utils.ts:286, 292) keeps the suite green, since the native RTL tests assert writingDirection only and the accessory snapshots never carry a textAlign. The writingDirection newly added to prefixStyles and suffixStyles (utils.ts:268, 279) has no test on either platform - the existing prefix/suffix tests assert presence and visibility, not style. Add the native counterparts (counter textAlign: 'right' in RTL, accessories without the physical margins) and one prefix/suffix writingDirection assertion.

persona: javascript, react-native-paper

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/note This holds on iOS only: Android ignores writingDirection, and on iOS it can reorder an affix that starts with punctuation, such as /100, though not a lone $. The input already gets the same writingDirection on every platform, so gating the affixes to web would make them disagree with it on iOS.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Withdrawing this finding

You're right that the input itself already carries the same ungated writingDirection: isRTL ? 'rtl' : 'ltr' on every platform (utils.ts:428 and :548), so the affixes are consistent with the field they sit next to rather than a new native behaviour out of scope — gating them to web would introduce the iOS mismatch you describe. Since Android ignores the property and a lone $ is unaffected on iOS, the only real exposure is an affix starting with punctuation under forceRTL, which the bidi reordering argument makes the more correct rendering anyway. Dropping the platform-gate ask and my suggested patch; the only piece I'd still keep is optional: the new prefix/suffix writingDirection has no assertion on either platform, so a one-line style assertion in the existing prefix/suffix tests would pin it.

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

color: onSurfaceVariant,
paddingEnd: PREFIX_END_PADDING,
writingDirection: isRTL ? 'rtl' : 'ltr',
},
isDisabled && styles.disabled,
];
Expand All @@ -273,17 +276,20 @@ export const getSharedTextInputStyleData = (
fontSize: INPUT_FONT_SIZE,
color: onSurfaceVariant,
paddingStart: SUFFIX_START_PADDING,
writingDirection: isRTL ? 'rtl' : 'ltr',
},
isDisabled && styles.disabled,
];

const leadingAccessoryStyles: StyleProp<ViewStyle> = [
styles.leadingAccessory,
isRTL && Platform.OS === 'web' && styles.leadingAccessoryRTL,
isDisabled && styles.disabled,
];

const trailingAccessoryStyles: StyleProp<ViewStyle> = [
styles.trailingAccessory,
isRTL && Platform.OS === 'web' && styles.trailingAccessoryRTL,
isDisabled && styles.disabled,
];
Comment on lines 284 to 294

@apex-sentinel-staging apex-sentinel-staging Bot Nov 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer raised on 96603e3: the code it pointed at changed.

🟡 Minor · RTL-only web styles are untestable and untested in the default (native) jest platform

The 'places the label on the right side when RTL' test asserts only toHaveProperty('start') and the accessory test asserts marginStart/marginEnd exists—both present on the non-web fallback path—so they pass even if the web branches are deleted. Any regression in leadingAccessoryRTL, trailingAccessoryRTL, the 'end' label offset, or the web textAlign flips ships silently.

Suggested change

Add at least one test with jest.mock of Platform.OS = 'web' (or a separate describe using the react-native-web preset) asserting end on the label wrapper, marginEnd on leadingAccessoryStyles, and textAlign: 'right' on the supporting text.

Details

Also raised here

Also raised at this location by persona react-native-paper: RTL tests assert only style-object keys, not the side the element renders on — places the label on the right side when RTL passes even if the label renders on the left: it only asserts the flattened wrapper style has a start key, and labelInlineProp emits start on native for BOTH LTR and RTL, so the RTL-specific behavior (positioning on the inline-end) is never observed — a TextInput rendering the label at start: 16 in RTL passes unchanged. The same applies to places the accessories on the right side when RTL, which asserts only that the flattened style carries marginStart/marginEnd keys, keys the pre-change styles.leadingAccessory/trailingAccessory already had, so it passes with the old styles and with the new leadingAccessoryRTL/trailingAccessoryRTL overrides removed. Both tests therefore guard nothing about RTL placement despite their names.

persona: maintainability, javascript, react-native-paper

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apex-sentinel-staging like

Fixed within previous comment.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. It helps us make these findings more useful.


Expand Down
68 changes: 67 additions & 1 deletion src/components/__tests__/TextInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ it('applies RTL text alignment and writing direction to the TextInput (outlined)
});
});

it('applies RTL writing direction to supporting text', async () => {
it('uses left text alignment and rtl writing direction for supporting text in RTL on native', async () => {
I18nManager.isRTL = true;

await render(
Expand All @@ -1048,6 +1048,7 @@ it('applies RTL writing direction to supporting text', async () => {
);

expect(screen.getByText('Hint', includeHiddenElements)).toHaveStyle({
textAlign: 'left',
writingDirection: 'rtl',
});
});
Expand Down Expand Up @@ -1421,6 +1422,71 @@ describe('on web in RTL', () => {
{ right: LABEL_START_OFFSET_WITHOUT_ACCESSORY }
);
});

it('uses physical margins for the accessories', async () => {
await render(
<TextInput
label="Email"
value=""
onChangeText={() => {}}
startAccessory={({ style }) => (
<View testID="web-rtl-leading" style={style} />
)}
endAccessory={({ style }) => (
<View testID="web-rtl-trailing" style={style} />
)}
/>
);

expect(screen.getByTestId('web-rtl-leading')).toHaveStyle({
marginStart: 0,
marginRight: 12,
});
expect(screen.getByTestId('web-rtl-trailing')).toHaveStyle({
marginEnd: 0,
marginLeft: 12,
});
});

it('aligns supporting text to the right and the counter to the left', async () => {
await render(
<TextInput
label="Email"
value="ab"
maxLength={10}
counter
supportingText="Helper"
onChangeText={() => {}}
/>
);

expect(
screen.queryByTestId('text-input-addendum-spacer', includeHiddenElements)
).not.toBeOnTheScreen();
expect(screen.getByText('Helper', includeHiddenElements)).toHaveStyle({
textAlign: 'right',
});
expect(screen.getByText('2/10', includeHiddenElements)).toHaveStyle({
textAlign: 'left',
});
});

it('renders the counter without supporting text', async () => {
await render(
<TextInput
label="Email"
value="ab"
maxLength={10}
counter
onChangeText={() => {}}
/>
);

expect(
screen.getByTestId('text-input-addendum-spacer', includeHiddenElements)
).toBeOnTheScreen();
expect(screen.getByText('2/10', includeHiddenElements)).toBeOnTheScreen();
});
});

it('shows prefix and suffix when the field is floating and hides them after value is cleared while blurred', async () => {
Expand Down
10 changes: 10 additions & 0 deletions src/components/__tests__/__snapshots__/TextInput.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ exports[`dims a disabled TextInput with TextInput.Icon accessories exactly once
"marginStart": 12,
"width": 24,
},
false,
{
"opacity": 0.38,
},
Expand Down Expand Up @@ -376,6 +377,7 @@ exports[`dims a disabled TextInput with TextInput.Icon accessories exactly once
"marginEnd": 12,
"width": 24,
},
false,
{
"opacity": 0.38,
},
Expand Down Expand Up @@ -685,6 +687,7 @@ exports[`renders filled TextInput with TextInput.Icon accessories 1`] = `
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -861,6 +864,7 @@ exports[`renders filled TextInput with TextInput.Icon accessories 1`] = `
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -1140,6 +1144,7 @@ exports[`renders filled TextInput with TextInput.Icon accessories when error is
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -1316,6 +1321,7 @@ exports[`renders filled TextInput with TextInput.Icon accessories when error is
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -1799,6 +1805,7 @@ exports[`renders outlined TextInput with TextInput.Icon accessories 1`] = `
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -1975,6 +1982,7 @@ exports[`renders outlined TextInput with TextInput.Icon accessories 1`] = `
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -2234,6 +2242,7 @@ exports[`renders outlined TextInput with TextInput.Icon accessories when error i
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down Expand Up @@ -2410,6 +2419,7 @@ exports[`renders outlined TextInput with TextInput.Icon accessories when error i
"width": 24,
},
false,
false,
null,
{
"borderRadius": 20,
Expand Down
Loading