Suppose you have a text input that should contain a space separated list of options. As the user is typing the next option the autocomplete should suggest a completion and on picking one it replaces the current word being typed. Real world examples would be the "To" field for email or a search input with multiple keywords and you want to autocomplete only one part of the bigger query string.
With the current API this is hard to implement because the autocomplete effectively hijacks the input field from you and writes directly to it giving you no control on how that selected mat-option should affect the value.
Proposal
Decouple the autocomplete from the form input so that it doesn't write the form control value directly and leave it up to the containing component to decide what to write on "optionSelected". The above example could then be implemented with something like
Motivation
Suppose you have a text input that should contain a space separated list of options. As the user is typing the next option the autocomplete should suggest a completion and on picking one it replaces the current word being typed. Real world examples would be the "To" field for email or a search input with multiple keywords and you want to autocomplete only one part of the bigger query string.
With the current API this is hard to implement because the autocomplete effectively hijacks the input field from you and writes directly to it giving you no control on how that selected mat-option should affect the value.
Proposal
Decouple the autocomplete from the form input so that it doesn't write the form control value directly and leave it up to the containing component to decide what to write on "optionSelected". The above example could then be implemented with something like
To see what the current behavior is with the above code: https://stackblitz.com/edit/angular-gaktkz
I believe these are all related issues:
Trying to achieve the above using "displayWith": https://github.com/angular/material2/issues/11796 https://github.com/angular/material2/issues/8436
Not exactly same use case as above but would be solved be decoupling autocomplete and the form control: https://github.com/angular/material2/issues/4863
Autocomplete overwriting the value that's being set via formControl.setValue(...) https://github.com/angular/material2/issues/10968 https://github.com/angular/material2/issues/8214