angular / angular/components

bug(datepicker): Duplicate marker on calendar pop up when inputting date that is outwith min/max dates

Abierto
#27,573 6 comentarios 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

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

I have set the min and max dates using their respective properties. When I type in a date that is after the max date, and then open the calendar, a marker appears on both the date I typed in and the max date. This behaviour could arguably be slightly confusing to the user but it is particularly misleading in the instance that the highlighted max date is actually disabled due to custom validation. The same issue can be seen for the minimum date.
![image](https://github.com/angular/components/assets/71448881/a2f4c43d-61f4-4ee1-be13-9cd381d7e33f)

### Reproduction

StackBlitz link: https://stackblitz.com/run?file=package.json (an example from the docs)
Steps to reproduce:
1. In datepicker-min-max-example.ts, adjust the max date so that it is not the last day of the month (so that the issue can be seen) e.g. change it to the 15th
2. In the input, type in a date which is after the max date - e.g. the 18th
3. Open the calendar and you will see that two dates are highlighted - the date that was typed in and the maximum date.
4. Provide a custom validator that would render the maximum date disabled e.g. if the max date was a Sunday but weekends are not allowed. Repeat steps 2 & 3 and you will see that this date is highlighted even though it is invalid.
5. Same steps for minimum date.

### Expected Behavior

I am expecting to see only one date highlighted on the calendar - just the (invalid one) that was typed in. If this is not desired, then it should still take into account other invalid/disabled dates through customer validator, so it should highlight the maximum valid date rather than the general maximum date regardless of its validity. Likewise for the minimum date.

### Actual Behavior

I saw two dates highlighted on the calendar - the date I typed in and the maximum date. The maximum date is also highlighted even when it has been rendered invalid by a custom validator, which could be misleading to users - this is the main issue. Likewise for the minimum date.

### Environment

- Angular: 16.1.6
- CDK/Material: 16.1.6
- Browser(s): Google Chrome
- Operating System (e.g. Windows, macOS, Ubuntu): Windows

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Reproduce el problema utilizando el ejemplo de StackBlitz y datepicker-min-max-example.ts, comprobando primero los pasos min/max y custom-validation descritos. Rastrea cómo el calendario marca la fecha introducida y las fechas límite y, a continuación, verifica que solo la fecha correspondiente permanezca resaltada cuando un límite no sea válido o esté deshabilitado.

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.