bug(autocomplete): Setting input value from code does not update autocomplete selected item
- Lingua principale
- TypeScript
- Stelle
- 25k
- Fork
- 6.8k
- Merge medio
- 1g 8h
- PR unite (30g)
- 91
Descrizione
### 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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con la riproduzione in src/app/example-component.ts dello StackBlitz collegato e traccia come la cancellazione del FormControl o del valore di input influisce sul completamento automatico. Conferma il comportamento in Chrome o Firefox: dopo la cancellazione e il nuovo focus, l'opzione selezionata in precedenza non dovrebbe più mostrare il segno di spunta né l'indicazione in primo piano della selezione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 55/100