Repository navigation
fix(text-input)!: correct MD3 states and accessibility - #5111
Conversation
|
Checks are failing |
There was a problem hiding this comment.
🟡 Changes recommended
Three moderate accessibility issues remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates TextInput to align MD3 indicator states and improve cross-platform accessibility.
Changes:
- Corrects filled-field colors and hover behavior.
- Adds accessibility relationships and platform-specific announcements.
- Updates accessory behavior, tests, examples, and migration guidance.
File summaries
| File | Summary |
|---|---|
src/components/TextInput/utils.ts |
Accessibility data and indicator color logic |
src/components/TextInput/TextInputIcon.tsx |
Decorative/actionable accessory behavior |
src/components/TextInput/TextInput.tsx |
Accessibility props and rendering updates |
src/components/TextInput/hooks.ts |
Hover state and announcements |
src/components/__tests__/TextInputStates.test.tsx |
Indicator state tests |
src/components/__tests__/TextInputAccessibility.test.tsx |
Accessibility behavior tests |
src/components/__tests__/TextInput.test.tsx |
Updated component tests |
src/components/__tests__/__snapshots__/TextInput.test.tsx.snap |
Updated snapshots |
example/src/Examples/TextInputExample.tsx |
Updated accessibility examples |
docs/6.x/docs/guides/migration.md |
Migration guidance |
Review details
Suppressed comments (1)
src/components/TextInput/TextInputIcon.tsx:142
- The
disabledprop is destructured above but is not forwarded toIconButton;aria-disabledalone does not activate IconButton's disabled styling (getIconButtonColor) or its disabled prop. A directly used named<TextInput.Icon disabled mode="contained" />can therefore remain visually enabled even though its handlers are suppressed; passdisabledthrough as well.
aria-disabled={disabled}
- Files reviewed: 10/10 changed files
- Comments generated: 2
- Review effort level: Lite (auto)
Note
Copilot is running an experiment and ran this review at Lite.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
32523ce to
a796f25
Compare
There was a problem hiding this comment.
Review by Claude
The PR description is out of date. It says outlined fields do not react to hover, and test plan step 4 says "Outlined does not change". The second commit makes outlined use onSurface and onErrorContainer on hover. Please update the description and the test plan. (via Claude, verify if it makes sense)
|
Review by Claude Android (Pixel 9 emulator)The field wrapper becomes a TalkBack stop that repeats the supporting text Steps: open the TextInput example and look at the filled field with the default "Supporting text". Then turn on Error and Counter. What happens: the Accessibility tree from agent-device on this PR, rest state: On main the What should happen: the supporting text and the counter are read once. Hiding the supporting text and counter nodes on native, as in the inline comment on (via Claude, verify if it makes sense) |
a796f25 to
1cc6527
Compare
499e555 to
447e0a8
Compare
447e0a8 to
34dfd52
Compare
34dfd52 to
0ec157a
Compare
The prefix and suffix render as soon as the field is focused or gets a value, while the label still rests where they are drawn and only then floats away. Without the input container fade, they showed at full opacity under the label for the whole float animation. Fade only the prefix and suffix with the label float value when a label is set, and keep their disabled dim, which the animated opacity replaces.
React Native 0.88 still has no described-by relationship on Android or iOS, so the hint fallback stays and only the version in the comment changes.
The snapshots main added for TextInput.Icon accessories now show decorative icons hidden from assistive technology, named actionable icons, no multiline prop on the icon, the filled onSurfaceVariant indicator, a read-only disabled input, and an input container without the fade and the second disabled dim.
The placeholder switched from the blank space to its text as soon as a labelled field took focus, while the label still rested over the input and only then floated away. Without the input container fade, the placeholder showed at full opacity under the resting label during the float animation. Track when the float value reaches the floated position, whichever animation moved it, and show the placeholder of a focused, empty, labelled field only from then on. The input stays visible to assistive technology. Value text set programmatically while the field is unfocused still appears while the label floats, as in 5.x.
The test only checked that there are no buttons and that the icon glyph is hidden. Both hold without hiding the decorative accessory, because a handler-less IconButton has no button role and Icon always hides its glyph, so the test passed with the decorative hiding removed. Give both accessories a test ID and check that the accessory elements are found only among hidden elements.
The field has the label Amount, which names the input, so query it by its accessible name instead of adding a test ID only for the test.
A touch that left the field cleared the hover state while the mouse was still over it. Touches already did not start a hover, so they no longer end one either, as react-native-web's own hover handling does.
A labelled field blanks its placeholder until the label floats away, so VoiceOver and TalkBack moving to the empty field did not hear it. The native hint now includes the placeholder while the field is empty, after any hint you pass.
The prefix and suffix were separate text next to the input, so screen readers read them as stops of their own or not with the field at all. They are now hidden from assistive technology and describe the input instead: on web through aria-describedby while they are rendered, and on Android and iOS through the hint.
Validating on every keystroke changed the error message with each input change, and every changed message queued another announcement on Android and iOS. An error is now announced once it has stayed the same for a second, so only the message the user stops at is read. An error that clears before then is not announced, and one that briefly clears and comes back is not announced again.
The input of a labelled field keeps a blank placeholder until the label floats, so VoiceOver on web did not read the placeholder at all. While the input's own placeholder is blank, the empty field is now described by a hidden copy of it through aria-describedby, as Android and iOS read it from the hint. Once the input shows the placeholder, the description drops it, so it is not read twice.
Describe how the placeholder of an empty labelled field describes it on web until the input shows it, alongside the hint on Android and iOS.
A decorative TextInput.Icon passed role, accessible, focusable, tabIndex and aria-hidden to its IconButton, but the wrapper View already hides the whole subtree with aria-hidden and pointerEvents none, and a TouchableRipple without a handler is a plain view that drops the button role and is not a keyboard focus stop. The decorative accessory test now runs on Android, iOS and web and checks the icon is not focusable.
Actionable icons without a name are already reported by the development warning, the same way Checkbox reports a missing name, so the props go back to IconButton's.
Checkbox and Switch check process.env.NODE_ENV for their development warnings, and TextInput.Icon was the only component reading __DEV__.
487d870 to
2a15877
Compare
On Android and iOS the supporting text and counter are hidden from assistive technology, as the prefix and suffix are everywhere, so tests need includeHiddenElements to find them by text. The input also no longer sets aria-valuenow and aria-valuemax when the counter reaches maxLength.
While the label rests over an empty field, the placeholder was ' '. TalkBack read that blank as the field's text and dropped its label: an empty "Email" field was announced as "Space, edit box". On Android the hidden placeholder is now empty, so TalkBack reads the label. iOS and web keep ' ', which iOS multiline fields need (react-native#31573). Follows callstack#5111, which made the empty field reachable (callstack#5197).
While the label rests over an empty field, the placeholder was ' '. A blank is read as the field's text: TalkBack announced an empty "Email" field as "Space, edit box" and dropped its label, and iOS reported the blank as the field's value. The hidden placeholder is now empty. Only iOS multiline fields keep ' ', which keeps their placeholder updating (react-native#31573), the reason the space was added. Follows callstack#5111, which made the empty field reachable (callstack#5197).
The 6.x migration guide gets the entries that were missing for the Dialog (#5072), FAB (#5110) and TextInput (#5111) changes. - Dialog: the Portal sample shows the 5.x form and the prop-based API section says `children` is gone. New sections cover `scrollable` in place of `Dialog.ScrollArea`, a function `icon` for the icon's color and size, plain views in place of `Dialog.Content` and `Dialog.Actions` outside a Dialog, and the layout changes. The actions row style has no replacement, and the guide says so. - FAB: what `visible={false}` now does, and that tests need `includeHiddenElements` to find a hidden FAB. - TextInput: a disabled field is always read-only. - Focus indicator: the Appbar sentence now says the parts read the bar's `theme` from context (#5218) and links to that section. Two notes for apps written against a 6.0 alpha cover the dialog's top spacing and the single dim of a disabled field; neither changes anything for 5.x users. Part of #4991.
An empty labelled TextInput hid its placeholder as a single space, and screen readers took that blank as the field's text: TalkBack on Android read "Space" instead of the label, and iOS reported a blank value. The hidden placeholder is now empty. iOS multiline fields keep the space, which their placeholder needs in order to update (react/react-native#31573). Follows #5111 (#5197).

Motivation
MD3 and a11y fixes. Breaking:
TextInput.Iconwithout a press handler is decorative and hidden; with one it needsaria-labeloraccessibilityLabel. Helper text is not in the field's name. Newaria-invalidandaria-describedbyprops (explicit wins). Disabled text uses one 38% opacity. Hover is web-only.Related issue
MD3 review.
Screenshots / Videos
pr5111-textinput-android.mp4
pr5111-textinput-ios.mp4
Test plan
TextInput example:
onSurfaceVariant, outlinedoutline->onSurface; with Errorerror->onErrorContainer. Focus wins.Fixes #5197