-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Autocomplete] allow clearing the value also programmatically #37738
Comments
Yes, I think including something like this could be a good thing. Ideally, the autocomplete would use a reducer internally and we could expose a dispatch function that would allow you to trigger different actions (similarly to how Base UI compound components work), but we're not there yet. |
@michaldudak your idea on how to implement this would have to be added to the I will add the |
Yes, it could live there, but it requires some bigger refactoring of the hook (which we plan to do anyway) |
Cool, let's keep it in mind for whenever we get to the refactor. |
+1, I just encountered this and came here searching for the issue |
+1, also encountered the same issue |
Duplicates
Latest version
Summary 💡
When the options for Autocomplete are likely to change over time, it means that a situation is likely that currently selected value is no longer available in the options. In such case Autocomplete starts spamming a "The value provided to Autocomplete is invalid." warning to the console.
It would be quite important to be able to handle the situation and for example then clear the value programmatically (=essentially call the same function that the manual clear button calls). Currently this does not seem to be possible.
Examples 🌈
SO thread about it with some code: https://stackoverflow.com/questions/76515033/mui-autocomplete-how-to-clear-value-when-options-change
Motivation 🔦
Better interface to handle an edge case
The text was updated successfully, but these errors were encountered: