Repository navigation
Conversation
|
Found potential problems with the pull request:
|
67cd8ad to
eab02b4
Compare
jacekAtCK
left a comment
There was a problem hiding this comment.
i think we need to change the PR title: fix! or a add a changelog note, other than that - lgtm :)
eab02b4 to
a837c18
Compare
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on 446280b. The verdict and the full list are in the summary comment.
| @@ -247,6 +247,7 @@ export const getSharedTextInputStyleData = ( | |||
| styles.supportingText, | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
Thanks for the feedback. It helps us make these findings more useful.
| 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, | ||
| ]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@apex-sentinel-staging like
Fixed within previous comment.
There was a problem hiding this comment.
Thanks for the feedback. It helps us make these findings more useful.
| const isControlled = props.value !== undefined; | ||
| const isRTL = direction === 'rtl'; | ||
| const hasAccessory = isRTL ? !!props.endAccessory : !!props.startAccessory; | ||
| const hasAccessory = !!props.startAccessory; |
There was a problem hiding this comment.
No longer raised on 96603e3: the code it pointed at changed.
🟡 Minor · Breaking hasAccessory/RTL accessory semantics not recorded in migration guide
An app that renders a lone endAccessory had the label offset account for it in RTL before this change; now the label rests over the trailing accessory's slot area. The PR title carries ! indicating a breaking change, but docs/6.x/docs/guides/migration.md has no section for it — the caution was added only to rtl.md.
Suggested change
Add a TextInput RTL section to docs/6.x/docs/guides/migration.md stating that startAccessory/endAccessory are now logical leading/trailing slots (no swap in RTL) and that the label offset keys off startAccessory only.
Details
persona: react-native-paper, maintainability · rule component-structure
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.
There was a problem hiding this comment.
@apex-sentinel-staging like
Updated the migration.md with a breaking change.
There was a problem hiding this comment.
Thanks for the feedback. It helps us make these findings more useful.
446280b to
96603e3
Compare
This comment has been minimized.
This comment has been minimized.
|
#5219 has landed the accessory swap removal and the web label, so when this PR is next, the rebase can shrink it to what only it does:
The supporting-text and counter alignment and the spacer stay as they are. |
96603e3 to
6400150
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 6400150. The verdict and the full list are in the summary comment.
| ) : hasCounter ? ( | ||
| <View style={styles.addendumSpacer} /> | ||
| ) : null} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thanks for the feedback. It helps us make these findings more useful.
| @@ -263,6 +265,7 @@ export const getSharedTextInputStyleData = ( | |||
| fontSize: INPUT_FONT_SIZE, | |||
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
/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.
There was a problem hiding this comment.
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.
6400150 to
348793c
Compare
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
marginRightfor the leading accessory andmarginLeftfor the trailing one. React Native Web resolves logical margins from adirprop on its own Views, so the old flip only worked with<html dir>. Physical sides also work with<View dir="rtl">.rightand the counterleft. On native they keepleftandright, since React Native mirrors them.Motivation
On web in RTL,
TextInputsupporting text, counter and accessory spacing could end up on the wrong side. This puts them on the correct side, including whendiris set on a nested container instead of<html>.Related issue
TextInput: in RTL, startAccessory and endAccessory render on the wrong sides, and on web the label overlaps the start accessory #5214
Screenshots / Videos
Test plan
I18nManager.forceRTL(true)on native, (you can use development builds and toggle a change in a menu drawer) anddir="rtl"on web.flatandoutlinedmodes.startAccessoryis on the right and theendAccessoryis on the left.