mui / mui/material-ui

[TextField] Attach `aria-errormessage` attribute

Open
#38,929 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accessibility scope: text field type: enhancement
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Duplicates
  • I have searched the existing issues
Latest version
  • I have tested the latest version
Summary 💡

I noticed that the TextField component does not take advantage of the aria-errormessage attribute. In this example

<TextField
    label="Name"
    size='small'
    fullWidth
    margin='normal'
    placeholder='What do you want to call it?'
    error={Boolean(errors.name)}
    helperText={errors.name?.message}
/>

The input that is rendered in the DOM has aria-invalid="true" and aria-describedby=":rl:-helper-text" which points to <p id=":rl:-helper-text" ...>Must be at least 2 characters</p>. It does not have aria-errormessage attribute set. Please see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage

Examples 🌈

No response

Motivation 🔦

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TextField component entry point and inspect how its input, error state, and helper text currently produce aria-invalid and aria-describedby. Read the linked aria-errormessage reference; done means the rendered error state exposes the requested attribute pointing to the error message while preserving the existing accessibility attributes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
accessibility, frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.