angular / angular/components

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

Abierto
#27,322 1 comentario 2 reacciones 0 asignados Ver en GitHub
area: material/datepicker P3
Lenguaje dominante
TypeScript
Estrellas
25k
Forks
6.8k
Merge medio
1 d 8 h
PR fusionados (30 d)
91

Descripción

### 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)

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la reproducción vinculada de StackBlitz y el flujo del date range picker de Angular Material usando mat-datepicker-toggle y valueChanges. Reproduce la selección de 6/18/2023 seguida de 6/24/2023 en la sección Changes y, después, compárala con la solución alternativa debounceTime(0). Hecho significa un evento valueChanges después de la fecha de inicio y otro después de la fecha de finalización.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, typescript
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.