Skip to content

fix(text-input)!: correct MD3 states and accessibility - #5111

Merged
Doberjohn merged 37 commits into
callstack:mainfrom
likevy:fix/textinput-md3-accessibility
Nov 19, 2026
Merged

Doberjohn merged 37 commits into
callstack:mainfrom
likevy:fix/textinput-md3-accessibility

Conversation

@likevy

@likevy likevy commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

MD3 and a11y fixes. Breaking: TextInput.Icon without a press handler is decorative and hidden; with one it needs aria-label or accessibilityLabel. Helper text is not in the field's name. New aria-invalid and aria-describedby props (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:

  1. Web hover: filled onSurfaceVariant, outlined outline -> onSurface; with Error error -> onErrorContainer. Focus wins.
  2. Enable Decorative leading icon and Clear text action. Tab into the field: icon skipped. Type, Tab: "Clear text" is read, Enter clears.
  3. Error + Counter: read once in the hint on iOS/Android; on web, an alert and the description.

Fixes #5197

Comment thread src/components/TextInput/utils.ts Resolved
@JKobrynski

Copy link
Copy Markdown
Collaborator

Checks are failing

Copilot AI left a 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.

🟡 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 disabled prop is destructured above but is not forwarded to IconButton; aria-disabled alone 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; pass disabled through 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.

Comment thread src/components/TextInput/utils.ts Resolved
Comment thread src/components/TextInput/utils.ts Resolved
@likevy
likevy force-pushed the fix/textinput-md3-accessibility branch from 32523ce to a796f25 Compare September 22, 2026 14:32

@satya164 satya164 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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)

Comment thread src/components/TextInput/utils.ts Resolved
Comment thread src/components/TextInput/hooks.ts Resolved
Comment thread src/components/TextInput/utils.ts Resolved
@satya164

satya164 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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 Pressable around the field is clickable, so React Native gives it a content description built from its child text that is not hidden. This PR removes aria-hidden from the helper text, so the wrapper node (it covers the field and the supporting text) now has the description "Supporting text". On main the same node has no description. With Error and Counter on, the wrapper reads "Please check the entered text, Characters entered 0 of 100". The input hint also contains that text. So a TalkBack user gets the same text on the wrapper and again in the hint of the field.

Accessibility tree from agent-device on this PR, rest state:

View "Supporting text"   clickable, bounds of field + supporting text
  TextView "Label"
  EditText
  TextView "Supporting text"

On main the View has no label.

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 utils.ts lines 602 to 606, also removes them from the wrapper description.

Android, Error and Counter on

(via Claude, verify if it makes sense)

@Doberjohn Doberjohn added this to the 6.0.0 milestone Oct 30, 2026
@likevy
likevy force-pushed the fix/textinput-md3-accessibility branch from a796f25 to 1cc6527 Compare October 30, 2026 14:10
@likevy
likevy force-pushed the fix/textinput-md3-accessibility branch 2 times, most recently from 499e555 to 447e0a8 Compare November 6, 2026 11:46
@likevy
likevy requested a review from Doberjohn November 6, 2026 11:47
@Doberjohn Doberjohn modified the milestones: 6.0.0, 6.0.0-beta.0 Nov 12, 2026
@Doberjohn Doberjohn added the needs pickup Work that has been started but needs someone to pick it up and continue. label Nov 13, 2026
@Doberjohn Doberjohn removed the needs pickup Work that has been started but needs someone to pick it up and continue. label Nov 13, 2026
@likevy
likevy force-pushed the fix/textinput-md3-accessibility branch from 447e0a8 to 34dfd52 Compare November 17, 2026 09:24
@Doberjohn Doberjohn assigned likevy and unassigned kachmashk Nov 17, 2026
@likevy
likevy force-pushed the fix/textinput-md3-accessibility branch from 34dfd52 to 0ec157a Compare November 17, 2026 14:49
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__.
@likevy
likevy force-pushed the fix/textinput-md3-accessibility branch from 487d870 to 2a15877 Compare November 19, 2026 14:10
@likevy
likevy requested a review from lukewalczak November 19, 2026 15:02
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.
@Doberjohn Doberjohn changed the title fix(text-input): correct MD3 states and accessibility fix(text-input)!: correct MD3 states and accessibility Nov 19, 2026
@Doberjohn
Doberjohn merged commit 03c8ca2 into callstack:main Nov 19, 2026
11 checks passed
datsiuk-ck added a commit to datsiuk-ck/react-native-paper that referenced this pull request Nov 19, 2026
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).
datsiuk-ck added a commit to datsiuk-ck/react-native-paper that referenced this pull request Nov 20, 2026
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).
Doberjohn added a commit that referenced this pull request Nov 20, 2026
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.
Doberjohn pushed a commit that referenced this pull request Nov 23, 2026
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextInput: an empty, unfocused TextInput with a label is hidden from screen readers

7 participants