-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
bug(MatAutocomplete): when using single mat-autocomplete with multiple inputs, panel does not open in some circumstances and displays incorrect option as selected #28362
Comments
Hello, I was wondering if we could get more information on this to understand what your need is. You can change the element that the autocomplete is attached to using the matAutocompleteOrigin directive together with the matAutocompleteConnectedTo input.
MatAutocomplete is designed to connect to a single element. I don't think that connecting autocomplete to more than one elements is a supported configuration. How come you need to connect one autocomplete to multiple inputs? Best Regards, Zach |
Thank you for the reply @zarend!
It's not exactly my case, but imagine that there are 50 input fields on the page, and each of them should offer the same 300 autocomplete options. If we instantiate a separate At most one This is essentially the scenario that was described here: https://stackoverflow.com/q/70781743 Another thing that is broken within Consider the following reproduction steps:
All-in-all, the Storing the state of these checkmarks within the |
Thanks for getting back to me, I think I see how reusing an autocomplete instance would be good for performance. That's a good point. Looks like MatAutocomplete is intended to support multiple triggers. There's support for the changing origin while it's open. https://github.com/angular/components/blob/main/src/material/autocomplete/autocomplete.spec.ts#L3654 I don't know off the top of my head why it's not working in this stackblitz. -Zach |
…le triggers Fixes that if one panel is tied to multiple triggers, it ends up becoming invisible because the original trigger resets the state after the next trigger picks it up. These changes avoid the state reset if the trigger has changed. Fixes angular#28362.
…le triggers Fixes that if one panel is tied to multiple triggers, it ends up becoming invisible because the original trigger resets the state after the next trigger picks it up. These changes avoid the state reset if the trigger has changed. Fixes angular#28362.
…le triggers (#28843) Fixes that if one panel is tied to multiple triggers, it ends up becoming invisible because the original trigger resets the state after the next trigger picks it up. These changes avoid the state reset if the trigger has changed. Fixes #28362. (cherry picked from commit 2f17c69)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Is this a regression?
The previous version in which this bug was not present was
14.2.7
Description
MatAutocomplete enters a broken state (invisible, but clickable), when the following conditions are met:
<mat-autocomplete>
instance is used by multiple<input>
sReproduction
StackBlitz link: https://stackblitz.com/edit/ajkqp1?file=src%2Fexample%2Fautocomplete-simple-example.html
Steps to reproduce:
Expected Behavior
The autocomplete panel for the "Number 1" input is now open.
Actual Behavior
The autocomplete panel was visible for a brief moment, and then disappeared.
In particular, the panel still exists and is clickable, but has
opacity: 0
. This style appears to have been set by the animation of the panel that has just been closed.Note that:
<input>
fields.<mat-autocomplete>
defined. Demo.<mat-autocomplete>
for multiple<input>
s used to work in Angular Material 14.2.7. Demo.Environment
The text was updated successfully, but these errors were encountered: