When one of the options in Autocomplete is selected, there is a slightly non-natural behavior when manipulating input text. After deleting e.g. the last letter, the list with possible options is filtered by input text. When you type this deleted letter again, the whole list with all options is displayed. Later, if you add another letter, filtering takes effect again.
You can try it on the first demo (Combo box) on Autocomplete page (https://material-ui.com/components/autocomplete/).
Type the beginning of one of the options, e.g. "Pulp": 
Hit enter or choose this option by clicking: 
Hit backspace to remove last letter (now filtering is active): 
Type "n" (now filtering is not active): 
Type any letter (now filtering is active again): 
Displaying the whole list of options with selected value highlighted looks right when you open the list with mouse click, but behavior described above looks a little confusing and may be recognized as a bug.
@eps1lon has anybody looked at this? I feel like it was somehow unnoticed as new issues are getting responses and this one not.
Can I try to solve this or are you already working on it? :) @k-rokicki
@montelius go ahead, and thanks for volunteering!
@montelius All yours. Please let us know if you no longer intend to work on this issue. If you're stuck at any point feel free to open a PR so a maintainer can take a look.
@eps1lon So I've figured out why this bug exists, but I'm not sure how to solve it. Here's the problem:
When an option is selected, the listbox of options is closed. When you either focus on the textbox again, or click the arrow down button, the entire list of options is shown, not just the option matching the input. That makes sense in that case, because the user probably wants to change the selected option and should be shown all options. That is controlled by this code in useAutocomplete.js:
and this code, specifically line 200:
The problem is that this case also applies to the case described in the issue, which does not make sense for the user. When an option is selected, it continues to be selected even though you remove the last letter, so when you type in the last letter again, inputValueIsSelectedValue in the code above becomes true.
So basically, you would probably want to make inputValueIsSelectedValue false if useAutocomplete was called because of a new keyboard input, and not because the textbox/arrow down button was clicked. However, I can't find a reasonable way to access that information from inside useAutocomplete. Can I get any help on how to solve this?
Alternatively, another possible solution is that an option stops being selected if you remove a letter from the input.
Thanks in advance!
Could you codify your expected behavior into a test or user interactions? You could open a PR with just the test and then we can collaborate on a potential fix.
@eps1lon Sounds good, thanks!
A proposed solution: we could create a new state that keep track of the pristine state of the input value. It's reset each time the popup open. When the input is pristine, we don't filter the options for the current value.
@oliviertassinari Yes, that is a solution! Should the state be represented as a prop passed to useAutocomplete?
@montelius from my perspective, the state should be internal to the useAutocomplete hook.
@oliviertassinari Sure, will look into it! :)