angular / angular/components

bug(datepicker): Date range picker emit repeated events after the first date is selected

Ouverte
#27,322 1 commentaire 2 réactions 0 personnes assignées Voir sur GitHub
area: material/datepicker P3
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

When a date range picker is opened and the start date is selected, two consecutive `valueChanges` event are triggered, and after the end date is selected the final event is triggered, in total 3 events happens instead of only two.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/shrtut?
Steps to reproduce:
1. Click on the `mat-datepicker-toggle` button.
2. Select a start date like: 6/18/2023
3. Notice on the _Changes_ section below that two events were triggered.
4. Select the end date: 6/24/2023.
5. A final event in logged on the _Changes_ section.

### Expected Behavior

After selecting the first date only a single `valueChanges` event should be triggered.

The expected behavior is show on the _Workaround Changes_ section where a `debounceTime(0)` is forced in order to remove the spurious repeated event.

### Actual Behavior

Two events are triggered after selecting the start date

### Environment

- Angular: 16.1.1
- CDK/Material: 16.1.1
- Browser(s): Firefox, Chrome.
- Operating System: Linux (Fedora)

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la reproduction StackBlitz liée et le flux du date range picker d’Angular Material utilisant mat-datepicker-toggle et valueChanges. Reproduisez la sélection de 6/18/2023 suivie de 6/24/2023 dans la section Changes, puis comparez-la avec le contournement debounceTime(0). Cela est terminé lorsqu’un événement valueChanges se produit après la date de début et un autre après la date de fin.

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

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.