mui / mui/material-ui

when TextField is used as a select, it isn't using error to mark the select element with aria-invalid

Open
#29,490 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

scope: select support: question type: expected behavior
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

When using the TextField as a select with error={true}, the field is not found to be invalid. This is because aria-invalid isn't set on the labeled field.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

aria-invalid isn't set on the select element

Expected Behavior 🤔

aria-invalid should be set to the value of error passed to TextField

Steps to Reproduce 🕹

codesandbox example with tests

The codesandbox shows:

  • TextField is invalid when error is true
  • TextField is not invalid when used as a select and error is true
  • TextField is invalid when used as a select when aria-invalid is passed through the SelectProps's SelectDisplayProps

Context 🔦

This makes it require extra steps to mark the select as invalid.

Your Environment 🌎

`npx @mui/envinfo`

using the codesandbox environment
Google Chrome Version 95.0.4638.54 (Official Build) (x86_64)

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 with the linked CodeSandbox and its src/App.test.tsx test, which reproduces TextField with error={true} both normally and as a select. Trace how SelectDisplayProps currently receives aria-invalid and verify the select case. Done means the select is marked aria-invalid from the TextField error prop without extra SelectDisplayProps configuration.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.