Description
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
MatAutocomplete's requireSelection
directive has a weird behaviour that isn't present in the documentation examples but is present in the Stackblitz link attached to the same example titled "Require an autocomplete option to be selected".
Reproduction
StackBlitz link: https://stackblitz.com/edit/vctmtb?file=src%2Fexample%2Fautocomplete-require-selection-example.css
Steps to reproduce:
- Click on field to open autocomplete panel
- Select any available option, for instance "One"
- Add an extra character to the input field, for instance "Onea"
- Focus out of the field by clicking outside
- See error (input is not reset)
NOTE: It's possible that it works as expected on the first try, so in that case, try to follow the same steps another time but with another option.
Expected Behavior
The form control should be cleaned out when detecting the option is not the same as one of the autocomplete's options. In this case, "Onea" is not the same as "One", so the input should reset and left empty.
Here you can see it working as expected in Angular Material's MatAutocomplete documentation.
Actual Behavior
The input is not cleaned out and stays with the wrong value.
Environment
- Angular: 17.2.0
- CDK/Material: 17.2.0
- Browser(s): Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): macOS