angular / angular/components

bug(material/datepicker): Adding a max to a datepicker input will fire valueChanges

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

Descripción

### Documentation Feedback

Currently the [documentation ](https://angular.io/api/forms/AbstractControl#valueChanges)only says that valueChanges will fire 'every time the value of the control changes' or 'each time you call enable() or disable()' however, I've also found valueChanges to fire if two inputs with datepickers rely upon one another for min and max.

My scenario is a period that has a start and end date. The start date cannot be after the end date, similarly the end date cannot be before the start. So basically my two form fields look like this:

```

```
and
```

```

What I've found is that the valueChanges of startDate will emit whenever the endDate is changed because of the startDate max.

It doesn't seem obvious in the documentation that setting the mib or max will cause the value of the control to change.

Here's a [stackblitz](https://stackblitz.com/edit/reactive-form-validation-angular-15-swfz9e?file=src/app/app.component.html).

Steps to reproduce:

1: Select a start date and see that its value is logged to the console via the valueChanges subscription on startDate.
2: Now make a change to the endDate field and note that the startDate valueChanges emits again.
3: Remove the [max]="period.get('endDate')?.value" from the startDate input and notice that the issue goes away.

### Affected documentation page

https://angular.io/api/forms/AbstractControl#valueChanges

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con la página de documentación afectada de AbstractControl.valueChanges y reproduce el escenario de StackBlitz enlazado. Confirma que al cambiar min/max del datepicker el control relacionado emite un evento y, después, actualiza la documentación para describir ese comportamiento; se considera terminado cuando la página cubre correctamente el caso reportado.

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

Evaluación

Stack tecnológico
angular, typescript
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.