bug(MatAutocomplete): matAutocomplete with initial value does not filter options and does not highlight selected
Is this a regression?
- [ ] Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
A MatAutocomplete field initialized with a value does not filter the list of options are mark selected item.
Reproduction
StackBlitz link: https://stackblitz.com/edit/vemaxm-6ktpyr?file=src%2Fexample%2Fautocomplete-auto-active-first-option-example.html
Steps to reproduce:
-
In the stackblitz, the formControl for the autcomplet is initialized with 'Two'
-
Click on the field
-
if I click on the option
it is as expected.
- after that if I click the 'clear' button
value is still selected
- reselect a value, lets say 'Two'
- delete the two last letters
Expected Behavior
The list of option should be filtered with the initial FormControl value The actual value should be marked as selected.
Resetting the value should remove the selected
deleting last letter of input keeps last selected option as selected
Actual Behavior
All options are displayed, and nothing indicates that a value is selected.
Resetting the form still displays a value as selected.
if not option exactly match the value, there should not be any selected option.
Environment
- Angular:
- CDK/Material:
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):
mat-autocomplete doesn't do any filtering, it just displays the mat-option that are projected and keeps track of the value. You can get it to work by changing startWith('') to startWith(this.myControl.value).
Ok that's fair, and resetting the selected is addressed with #27652 but what about the resetting selected when there is a partial value, or selecting when the value is the same, but was not selected in the dropdown?
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.