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

[material-ui][Autocomplete] Using limitTags prevents clicking buttons outside of autocomplete while autocomplete is focused #41689

Open
wouterh opened this issue Mar 28, 2024 · 3 comments
Assignees
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material

Comments

@wouterh
Copy link

wouterh commented Mar 28, 2024

Steps to reproduce

Link to live example: issue is also in the MUI docs

Steps:

  1. Select options until there are more than limitTags options selected
  2. Try to click a button outside of the autocomplete (e.g. the 'expand code' button)

Current behavior

The autocomplete is unfocused, but the click on the button is ignored.

Expected behavior

The click is also propagated to the button.

Context

We have a form with an AutoComplete where we set limitTags to prevent the AutoComplete from growing indefinitely. When people make a change to the selection in the AutoComplete and immediately click our 'Save changes' button, the click is not propagated to the button and the changes are not saved.

Your environment

Tested on latest Chrome (linux and mac) and Firefox (linux).

Search keywords: Autocomplete limitTags

@wouterh wouterh added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 28, 2024
@zannager zannager added the component: autocomplete This is the name of the generic UI component, not the React module! label Mar 28, 2024
@ZeeshanTamboli
Copy link
Member

The limitTags prop is only applied when there's a blur event. Clicking the button outside of the autocomplete triggers a blur event for the autocomplete. Users won't see the tags being limited until they click outside of the autocomplete. Wouldn't it be better to show the limited tags all the time (#21328)? If so, would this solution work for you: #21328 (comment)? I'm suggesting this because I believe it would offer a better user experience for your use case.

@ZeeshanTamboli ZeeshanTamboli added package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 30, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [Autocomplete] Using limitTags prevents clicking buttons outside of autocomplete while autocomplete is focused [material-ui][Autocomplete] Using limitTags prevents clicking buttons outside of autocomplete while autocomplete is focused Mar 30, 2024
@wouterh
Copy link
Author

wouterh commented Apr 3, 2024

Adding the renderTags in #21328 (comment) does solve the click blocking on buttons outside of the AutoComplete. The solution is not ideal though, since there is then no easy way to see all selected elements while filling in the form, which is also confusing for our users.

@ZeeshanTamboli
Copy link
Member

I'm unsure if we can keep both behaviors. I'll leave this issue open for now.

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