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

MuiAutocomplete component- getOptionLabel and aria-label needs to be different, could not able to achieve it #43715

Closed
sowji-code opened this issue Sep 11, 2024 · 3 comments
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@sowji-code
Copy link

sowji-code commented Sep 11, 2024

In the MuiAutocomplete component,
image
On inspecting one of the selected Option, for example: "Male" then for accessibility it should display aria-label as "Remove Male" by keeping the Option label text as "Male".

image

Tried updating code in the
renderInput={params =>
as
'role': 'button',
'aria-label': 'remove' + params.inputProps.value,
but not working.
Looking for a solution.

Search keywords:

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 11, 2024
@oliviertassinari oliviertassinari added the component: autocomplete This is the name of the generic UI component, not the React module! label Sep 11, 2024
@ZeeshanTamboli
Copy link
Member

You can use the chip slotProps slotProps.chip:

<Autocomplete
   ...
   slotProps={{ chip: { 'aria-label': `Remove ${option}` } }} 
/>;

See the API documentation for more details.

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

We value your feedback @sowji-code! How was your experience with our support team?
If you could spare a moment, we'd love to hear your thoughts in this brief Support Satisfaction survey. Your insights help us improve!

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 12, 2024
@ZeeshanTamboli ZeeshanTamboli added the package: material-ui Specific to @mui/material label Sep 12, 2024
@sowji-code
Copy link
Author

the provided solution didn't work. May be because of the version issue.
The below code worked perfectly.

renderTags={(values, props) => {
return (
<>
{values.map((value, i) => (
<Chip className=" MuiAutocomplete-tag MuiChip-sizeSmall"
label={value.label}
aria-label={Remove ${value.label}}
onDelete={e => props({ index: i }).onDelete(e)}
/>
))}
</>
);
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

No branches or pull requests

4 participants