bug(autocomplete): Setting input value from code does not update autocomplete selected item
- Langage dominant
- TypeScript
- Étoiles
- 25k
- Forks
- 6.8k
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 91
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
Autocomplete works beautifully when working from the user inputs.
When we set the value from the code-behind (either via FormControl or on the element directly) the selected option does not update.
In the attached example we need to clear the input from code, but the previously selected option still has the "selected" checkmark and foreground color.
### Reproduction
StackBlitz link: [components-issue-hmgdm3](https://stackblitz.com/edit/components-issue-hmgdm3?file=src%2Fapp%2Fexample-component.ts)
Steps to reproduce:
1. Select an option from the autocomplete
2. Clear the selection by using the button
3. Focus the input and you can see the previously selected option still having the "selected" indicators (checkmark and foreground)
### Expected Behavior
The autocomplete is supposed to remove the selected indication on the last selected option when the value of our input is cleared
### Actual Behavior
The autocomplete keeps previously selected option as "selected"
### Environment
- Angular: 16.2.1
- CDK/Material: 16.2.1
- Browser(s): Chrome, Firefox latest
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 11
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par reproduire le problème dans src/app/example-component.ts du StackBlitz lié et suivez l’effet de la suppression du FormControl ou de la valeur de saisie sur la saisie semi-automatique. Confirmez le comportement dans Chrome ou Firefox : après la suppression et le nouveau focus, l’option précédemment sélectionnée ne doit plus afficher sa coche ni l’indication visuelle de sélection au premier plan.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- angular, typescript
- Domaine
- frontend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Plutôt claire
- Accessibilité débutants
- 55/100