bug(autocomplete): optionSelected and onChangeCallback is called before the animation completes
- 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?
- [X] Yes, this behavior used to work in the previous version
### The previous version in which this bug was not present was
v16.1.8
### Description
There is a _setValueAndClose method in the MatAutocompleteTrigger class that doesn't take into account the time to complete the animation, this has even been flagged todo but still not fixed. Currently, if we in optionSelected decide to clear the array used in ngFor for mat-option, we will get the array cleared before the panel closes and there will be a corresponding jump

@crisbeto
### Reproduction
StackBlitz link: https://components-issue-v4ujjj.stackblitz.io
Steps to reproduce:
1. put the focus in the field
2. pick a value from the list
### Expected Behavior
the optionSelected event will be called after the animation is complete, the menu will not jump after the array is cleared
### Actual Behavior
optionSelected event was triggered without waiting for the animation to complete, clearing the array caused the panel to jump
### Environment
- Angular: 16.2.12
- CDK/Material: 16.2.14
- Browser(s): google chrome v126.0.6478.127
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par la classe MatAutocompleteTrigger et sa méthode _setValueAndClose, puis reproduisez le comportement à l’aide du StackBlitz lié en sélectionnant une option tout en vidant le tableau mat-option ngFor dans optionSelected. Comparez le timing des événements avec l’animation du panneau d’autocomplétion ; le travail est terminé lorsque optionSelected et onChangeCallback ne provoquent pas de saut du panneau avant la fin de l’animation.
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é
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 42/100