-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(material/autocomplete): don't assign to model value while typing when requireSelection is enabled #27572
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
fix(material/autocomplete): don't assign to model value while typing when requireSelection is enabled #27572
Conversation
I had to add and remove the merge label to verify that the change will be merged in the right branch. |
…when requireSelection is enabled Follow-up to angular#27423 based on the feedback. Usually `mat-autocomplete` assigns to the model as the user is typing which may not be desired when `requireSelection` is enabled, because at the end of the selection either an option value will set or it'll be reset. These changes add a condition so that the value isn't assigned while typing and `requireSelection` is enabled.
2a775d8
to
e342192
Compare
…when requireSelection is enabled (#27572) Follow-up to #27423 based on the feedback. Usually `mat-autocomplete` assigns to the model as the user is typing which may not be desired when `requireSelection` is enabled, because at the end of the selection either an option value will set or it'll be reset. These changes add a condition so that the value isn't assigned while typing and `requireSelection` is enabled. (cherry picked from commit 77ffdf9)
Regarding your early comments in previous thread and especially this one, this fix means that despite being against the generic expectations of not interacting directly with the DOM while dealing with reactive forms (quoting you) this is the actual way of filtering autocomplete options ? I understand the reasoning behind this fix, but I'd double check before propagating updated guidelines inside our project. |
Yes, I had to make the tradeoff because it would've been a weird experience if the form control was emitting events with the string value while the user is typing and then a |
Make sense, even if it would have been easier for my use case to filter out null value rather than switching source. Controls "valuesChanges" stream was very convenient especially to chain filter / debounce operators. I'll figure that out, thanks for the confirmation. |
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. |
Follow-up to #27423 based on the feedback. Usually
mat-autocomplete
assigns to the model as the user is typing which may not be desired whenrequireSelection
is enabled, because at the end of the selection either an option value will set or it'll be reset.These changes add a condition so that the value isn't assigned while typing and
requireSelection
is enabled.