Skip to content

[autocomplete] freeSolo value always changes to first matching item when you modify previous match #27137

@mbyrne00

Description

@mbyrne00

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.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

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)).

  1. Enter "Shawshank", arrow down and select the matching "The Shawshank Redemption" option. The value will be shown below
  2. Use your keyboard to remove "The" from the start of the word and hit enter
  3. 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)
  4. Now remove the word "Shawshank" and hit enter and the value changes to "The Redemption"
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: autocompleteChanges related to the autocomplete. This includes ComboBox.type: bugIt doesn't behave as expected.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions