Autocomplete will not update value for freeSolo if you delete text from a previous match and hit enter. Instead the select always interprets the enter key as selecting the first option.
Current Behavior 😯
Select menu takes over and selects first item on enter instead of accepting the custom freeSolo text after modification. Hitting esc on the keyboard to force menu shut is the only way to make it work without further modification.
Expected Behavior 🤔
Expect that hitting enter with custom text changes the value to that text when freeSolo option is enabled.
Steps to Reproduce 🕹
Forked off the demo material-ui freeSolo example. Only changes being that value shown and second example removed.
https://codesandbox.io/p/devbox/material-demo-forked-3zjdly (Updated demo to use Material UI v9 (latest)).
- Enter "Shawshank", arrow down and select the matching "The Shawshank Redemption" option. The value will be shown below
- Use your keyboard to remove "The" from the start of the word and hit
enter
- BUG: Value changes back to "The Shawshank Redemption" and the value below shows "The Shawshank Redemption" instead of the desired updated value "Shawshank Redemption" (being
freeSolo)
- Now remove the word "Shawshank" and hit
enter and the value changes to "The Redemption"
- Now using keyboard, delete "The" and type "Shawshank" at the start (keeping space between words) and hit enter and the value is successfully updated to "Shawshank Redemption" (this is what we expected in step 3).
As you can see we used two paths to try to update the text value to "Shawshank Redemption" and the user would expect both (step 3 and step 5 to work the same).
Context 🔦
Consistent value setting for users.
Your Environment 🌎
- Chrome Version 91.0.4472.114 (Official Build) (x86_64)
- MacOS
Autocomplete will not update value for
freeSoloif you delete text from a previous match and hitenter. Instead the select always interprets theenterkey as selecting the first option.Current Behavior 😯
Select menu takes over and selects first item on
enterinstead of accepting the customfreeSolotext after modification. Hittingescon the keyboard to force menu shut is the only way to make it work without further modification.Expected Behavior 🤔
Expect that hitting
enterwith custom text changes the value to that text whenfreeSolooption is enabled.Steps to Reproduce 🕹
Forked off the demo material-ui
freeSoloexample. Only changes being that value shown and second example removed.https://codesandbox.io/p/devbox/material-demo-forked-3zjdly (Updated demo to use Material UI v9 (latest)).
enterfreeSolo)enterand the value changes to "The Redemption"As you can see we used two paths to try to update the text value to "Shawshank Redemption" and the user would expect both (step 3 and step 5 to work the same).
Context 🔦
Consistent value setting for users.
Your Environment 🌎