-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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] freeSolo
prop not working
#41133
Comments
freeSolo
prop not working
Hey @MPavaoDS, thanks for the report! May I ask you to provide a minimal reproduction test case with the latest version? This would help a lot. I tried creating a repro myself, but I wasn't able to without knowing how the react hooks form is set up. A live example would be perfect. This StackBlitz sandbox template may be a good starting point. Thank you! |
Hi @DiegoAndai, thanks your your answer. I have added the minimal reproduction test case to that Stackblitz project, let me know if you can see it. |
Hey @MPavaoDS, unfortunately, I cannot see it. When you edit the sandbox, it creates a fork, which differs from the link I provided. Could you share the link to the forked one with your reproduction? Thanks! |
Sorry about that, here it is: https://stackblitz.com/edit/stackblitz-starters-hyzfr1?file=src%2FApp.jsx |
Does this work for you?: https://stackblitz.com/edit/stackblitz-starters-rcpccx?file=src%2FApp.jsx This used the |
It seems to work on my local code as well. Thank you for your help! |
That's good to hear! I'll close this issue. Please reach out if you have any other questions. |
The problem in depth
I have a MUI Autocomplete Component wrapped in an react-hook-form Controller. I want the Autocomplete to behave like Select and Text Field: meaning that the user either chooses an option from a list or if it doesn't exist in the list, the user can type a new option that will be later added to the database where the list comes from. For that, I added the props "freeSolo" and "autoSelect" to the Autocomplete.
So far I have managed to make the Select part work, but not the text input one. I have searched in several places but I didn't find a solution to my problem. Here's my code:
And the users list should look something like this:
I tried adding the following props to the Autocomplete:
But now, because my users list has both numbers and strings, it's throwing the error:
Your environment
`npx @mui/envinfo`
Search keywords: autocomplete, freeSolo
Order ID: 74223
Search keywords:
The text was updated successfully, but these errors were encountered: