-
Notifications
You must be signed in to change notification settings - Fork 6.8k
bug(Autocomplete): matAutocomplete with control initial value does not highlight value in options with check icon #29422
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
Comments
In your component, try this:
and in the html I guess that the icon just appears when you select by yourself an option. I checked the mat-autocomplete api and there's no way to do it. Also tried to add the [selected] in the mat-option without any good results. |
#27652 Here was a bug fixing with resetting. In my opinion, it is a fair and very useful feature to set the initial value without all these steps described by @GCancinoH above. |
In addition to this issue, I noticed if you attempt to capture the first and last options using the MatAutocomplete class, it retains the original values when the list was originally set and filtered. This used to work in Angular Material version 13/14 but no longer does. I do believe both of these issues have something to do with how options are set as selected. |
Any plans to fix this issue? |
…trol Currently, when we have some initial value in formcontrol those are not marked as selected, this fix will check the initial value and if its matched, will be marked as selected. Fixes angular#29422
…trol Currently, when we have some initial value in formcontrol those are not marked as selected, this fix will check the initial value and if its matched, will be marked as selected. Fixes angular#29422
Is this a regression?
The previous version in which this bug was not present was
No response
Description
A MatAutocomplete field initialized with a control value does not highlight item in options
Reproduction
StackBlitz link: https://stackblitz.com/edit/saqfud?file=src%2Fexample%2Fautocomplete-filter-example.ts,src%2Fexample%2Fautocomplete-filter-example.html,src%2Fexample%2Fautocomplete-filter-example.css
Steps to reproduce:
Expected Behavior
Second one option is highlighted

Actual Behavior
second option is not highlighted

Environment
The text was updated successfully, but these errors were encountered: