Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Select] Form Control examples that contain Select do not pass WAVE accessibility for labels #32495

Open
2 tasks done
marcusjwhelan opened this issue Apr 28, 2022 · 9 comments
Assignees
Labels
accessibility a11y component: FormControl The React component component: select This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation

Comments

@marcusjwhelan
Copy link

marcusjwhelan commented Apr 28, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Using wave on the Select component examples has the error on all select fields

Missing form label

A form control does not have a corresponding label.

I was finally able to fix the issue like this

<FormControl sx={{ minWidth: 120 }}>
  <InputLabel id={'label-for-category'} htmlFor={'category-select-input-id'}>Category</InputLabel>
  <Select
    label={'Category'}
    labelId={'label-for-category'}
    id={'category-select'}
    value={state.category}
    inputProps={{'id': 'category-select-input-id'}}
    onChange={(event) => handleChange(event, 'category')}
  >
    <MenuItem value={''}>
      <em>None</em>
    </MenuItem>
    <MenuItem value={10}>School</MenuItem>
    <MenuItem value={20}>Work</MenuItem>
    <MenuItem value={30}>Vacation</MenuItem>
  </Select>
</FormControl>

Where I needed to add an htmlFor to the label and add the associated id to the inputProps of the Select

The only select examples that do not have this error are the native examples because they have aria-label on them.

Expected behavior 🤔

Examples to pass WAVE when on the bottom of the page there are directions on how to pass accessibility but these in fact don't work for the form Control label. Removing them actually doesn't add any errors.

Steps to reproduce 🕹

Steps:

  1. Go to Select component model example page
  2. Run Wave

Context 🔦

Proper examples for accessibility

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@marcusjwhelan marcusjwhelan added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 28, 2022
@danilo-leal danilo-leal changed the title Select in Form Control examples do not pass WAVE accessibility for Labels [Select] Form Control examples that contain Select do not pass WAVE accessibility for labels May 3, 2022
@danilo-leal danilo-leal added component: select This is the name of the generic UI component, not the React module! component: FormControl The React component labels May 3, 2022
@siriwatknp siriwatknp added docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 25, 2022
@luchn49
Copy link

luchn49 commented May 31, 2022

The reason is that the id prop isn't broadcasted down to InputComponent (from here).

When using the native prop, the id would be broadcasted down to the select element and associated with the label. But it might lead to other issues:

  • The list items are rendered as a li with menuitem role instead of option element —> not able to open the menu 🤦🏽‍♂️
  • There’re new issues that are kind of similar to the original issue...

BTW, not sure if anyone is already working on a fix. If not, I'd be happy to make a contribution.

@dharshi1614
Copy link

Hi

@dharshi1614
Copy link

I would like to solve multi line input error any suggestions on this

@dharshi1614
Copy link

Iam trying to contact the participants but couldn’t do it.please share ur email id so that I can connect n discuss

@nate-summercook
Copy link
Contributor

How come there hasn't been any movement on this issue? Does the mui project not care about accessibility?
Judging from @luchn49 's comment it doesn't seem to be a documentation issue only, but a fundamental design problem.

As my project wants (and needs) to take accessibility seriously, such issues really cause a big pain for us, as we rely heavily on mui components.

@PenghaiZhang
Copy link

PenghaiZhang commented Jul 10, 2024

Any update on this issue in July 2024 ?? The product I am working on also needs to address this accessibility issue.

@guillenjs
Copy link

guillenjs commented Nov 1, 2024

Are there any updates on this issue? I am still encountering this problem in MUI V6.1.6. This is also an issue on the documentation on your website. https://mui.com/material-ui/react-select/

When tested with WAVE there are 20 missing labels and 16 orphaned labels.

@fetters5
Copy link

fetters5 commented Nov 1, 2024

I agree would love to know how to fix this so we can get make our compliance office happy

@guillenjs
Copy link

I think I have found a solution that is not included in the documentation.

For example this is the basic select provided in the documentation. If you use WAVE to test you will get the alert of Missin form label and orphaned label.

<FormControl fullWidth>
  <InputLabel id="demo-simple-select-label">Age</InputLabel>
  <Select
    labelId="demo-simple-select-label"
    id="demo-simple-select"
    value={age}
    label="Age"
    onChange={handleChange}
  >
    <MenuItem value={10}>Ten</MenuItem>
    <MenuItem value={20}>Twenty</MenuItem>
    <MenuItem value={30}>Thirty</MenuItem>
  </Select>
</FormControl>

Instead of adding the id as stated in the documentation you can use inputProps to add the
inputProps="demo-simple-select"
and on the inputLabel component add the following
htmlFor="demo-simple-select"

The final component looks like the following and it seems to make WAVE happen. Let me know if anyone has any thoughts.

<FormControl fullWidth>
   <InputLabel htmlFor="demo-simple-select" id="demo-simple-select-label"> Age </InputLabel>
     <Select
       labelId="demo-simple-select-label"
       value={age}
       label="Age"
       inputProps={{ id: "demo-simple-select" }}
       onChange={handleChange}
    >
       <MenuItem value={10}>Ten</MenuItem>
       <MenuItem value={20}>Twenty</MenuItem>
       <MenuItem value={30}>Thirty</MenuItem>
    </Select>
</FormControl>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: FormControl The React component component: select This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

No branches or pull requests

9 participants