bug(mat-datepicker): Datepicker cannot be closed when animating
- 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
Introduced in https://github.com/angular/components/pull/25843
### Description
We have implemented a year-only-picker using mat-datepicker in listening to the (yearSelected) event and then closing the datepicker manually. However, if the user selects a new year fast enough the datepicker is still opening and animating (_isAnimating is true) and therefore the datepicker is not closed. This was introduced in https://github.com/angular/components/pull/25843
The problem is that the `_isAnimating` property and the `_animationDone` subject are both not exposed through public API so we cannot wait for the animation to be finished to close the picker. However, exposing it would be not a good solution as this would require us to have knowledge of the internals of the component to implement the solution. Rather, the datepicker should be fixed so the close event is scheduled for after when the animation is finished.
Thanks!
### Reproduction
StackBlitz link:
It simulates opening the datepicker and then closing it very fast through setTimeout to visualize the issue.
https://stackblitz.com/edit/datepicker-bug-material
### Expected Behavior
Either datepicker will close even if animating or datepicker will be scheduled for closing so it closes at the end of the animation.
### Actual Behavior
Datepicker is not closing while animating
### Environment
- Angular: 16.2.8
- CDK/Material: 16.2.7
- Browser(s): Chrome Version 117.0.5938.149 - all browsers.
- Operating System (e.g. Windows, macOS, Ubuntu): macOs 13.2.1 - all operating systems
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par la reproduction StackBlitz liée et l’implémentation du datepicker Angular Material, en vous concentrant sur le comportement de fermeture lorsque le datepicker est en cours d’ouverture ou d’animation. Le correctif est terminé lorsque la sélection rapide d’une année ferme toujours le datepicker, soit immédiatement, soit après la fin de l’animation, et que ce comportement est couvert par les tests datepicker pertinents.
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
- 45/100