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 :)
| fontWeight: bodySmall.fontWeight, | ||
| textAlign: 'left', | ||
| }, | ||
| counter: { |
There was a problem hiding this comment.
i noticed while testing RTL that the without helper text is on the wrong side when we toggle the rtl on. With the supporting text it's correctly placed on the left as it should.
There was a problem hiding this comment.
I don't think I get it. Do you mean that the helper text is on the wrong side while using RTL? Or that the helper should be on the left side either we use LTL or RTL?
There was a problem hiding this comment.
Although I found an issue where the counter was moved to a helper place if helper was empty and while RTL. I've pushed a fixed for that!
| * Variant-specific styles | ||
| */ | ||
|
|
||
| const labelInlineProp = |
There was a problem hiding this comment.
I'm not that familiar with RTL, but it seems like here we may have an unnintended behaviour.
Web RTL works only when the app sets <html dir="rtl">, but RN-web takes the direction from the parent View, right?
So with <View dir="rtl">, the label stays on the left it overlaps with end accessory and the leading accessory touches the edge. We may just mention that in the docs though.
There was a problem hiding this comment.
Good catch! I updated the rtl.md doc with that.
eab02b4 to
a837c18
Compare
|
/review |
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
src/components/TextInput/utils.ts:246 |
New RTL web branches for label, margins and helper never execute in any test |
src/components/TextInput/utils.ts:286 |
RTL-only web styles are untestable and untested in the default (native) jest platform |
src/components/TextInput/hooks.ts:333 |
Breaking hasAccessory/RTL accessory semantics not recorded in migration guide |
Not in the reviewers' prompt (1 file)
src/components/__tests__/__snapshots__/TextInput.test.tsx.snap: generated or a lockfile, so its lines were left out
Reviewed with this repository's own Sentinel configuration (677ab9f2b2cf).
💬 Talking to Sentinel
In a finding's thread, reply with:
| 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.
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.
🟡 Minor · New RTL web branches for label, margins and helper never execute in any test
Because jest runs the react-native preset (Platform.OS === 'ios'), isRTL && Platform.OS === 'web' is false in every test, so the four new web-only branches (leadingAccessoryRTL/trailingAccessoryRTL, textAlign: 'right' on supporting text, textAlign: 'left' on the counter, [labelInlineProp]: 'end') never execute. The three new RTL tests actually assert the native/LTR outcomes (textAlign: 'left', marginStart/marginEnd) under misleading names, so a regression dropping the web flip would leave the suite green.
Suggested change
Add tests that run with Platform.OS mocked to 'web' (or a dedicated web project) asserting end/start on the label wrapper, the flipped accessory margins and textAlign: 'right' on the helper; rename the three new tests to say which platform they cover.
Details
Also raised here
Also raised at this location by persona react-native-paper: Counter alignment untested on web and native RTL never asserts the added 'right' — The two new supporting-text/counter tests both run on native (Platform.OS === 'web' is false under the Jest RN preset), so the 'right'/'left' values this PR added to supportingTextStyles/counterStyles are never exercised: the supporting-text test asserts textAlign: 'left', which is exactly what styles.supportingText already had and what the pre-change code produced, so it passes without this diff. The web RTL branch — the one the linked issue is about (label overlapping the start accessory, helper alignment) — has no test at all, including the end/start label-inline prop switch.
Also raised at this location by persona senior-developer: New RTL tests assert LTR/native values under RTL names — places the helper on the right side when RTL asserts textAlign: 'left' (the LTR/native value) and places the accessories on the right side when RTL only checks that marginStart/marginEnd exist as keys, which the base styles satisfy in LTR too. Both titles claim a side/side-placement property they never check, and the accessory assertion would also pass if the margins were dropped from the base styles. Assert the concrete values (expect(leadingStyle.marginStart).toBe(12)) and rename to what is actually verified.
Also raised at this location by persona maintainability: Test title says accessories are placed "on the right side" but asserts both sides — places the accessories on the right side when RTL asserts a marginStart on the leading accessory and a marginEnd on the trailing one — i.e. both sides of the row — so the name describes only half of what it checks and will mislead the next reader of a failure. Rename to something like "flips accessory margins to logical sides when RTL". The marginStart/marginEnd keys also exist in LTR, so this assertion does not pin the RTL behavior the name claims.
persona: senior-developer, react-native-paper, maintainability
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.
| 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.
🟡 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.
| 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.
🟡 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.
TextInputno longer swapsstartAccessoryandendAccessoryby hand in RTL. The row already mirrors through flex direction, so the swap flipped the accessories back to the wrong side.startAccessoryis always the leading slot andendAccessoryis always the trailing slot.hasAccessorynow depends only onstartAccessory.endinstead ofleft, and withstartotherwise.leadingAccessoryRTLandtrailingAccessoryRTLstyles.rightand the counterleft.textAlign: 'left'and the counter keepsright. React Native mirrors these under RTL.Motivation
In RTL layouts the
TextInputlabel, helper text, counter and accessories were placed on the wrong side. Some were mirrored twice, and some used physicalleft/rightvalues. This change places them on the correct side on native and web.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.