feat(MatDatepicker): Expose access to MatCalendar used in MatDatepicker
- Lenguaje dominante
- TypeScript
- Estrellas
- 25k
- Forks
- 6.8k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 91
Descripción
#### Feature Description
Expose access to MatCalendar instance that is created under the hood when using datepicker.
#### Use Case
I have requirement to allow user to type into the input date in proper format, and if datepicker is opened, it should update its state by showing typed in date. This is not possible using current api state. What I do now, is a nasty hacking - accessing private members of datepicker.
so, in my component, I have to
```
get calendar(): MatCalendar | undefined {
// this is soooo baaad and soo hacky to get that calendar instance......
// moreover, calendar can actually be null - when its closed.
// @ts-ignore
return this.datepicker._popupComponentRef?.instance._calendar;
}
this.myInputField.valueChanges.pipe(filter(v => v), debounceTime(250)).subscribe(v => {
const calendar = this.calendar;
// console.log('dp', this.datepicker);
// console.log('cal', this.calendar);
//sooooooooo much haaaaaaaaaaaxing
if (calendar) {
calendar.activeDate = v;
}
```
I think its perfectly valid to manipulate calendar state from the component code. This will obviously stop working when I swtich to touchUI. Therfore, API that provides reliable way to access calendar would be even more convinient.
Guía de contribución
Línea de trabajo
Comienza localizando los puntos de entrada de MatDatepicker y MatCalendar y revisando cómo se accede actualmente a la instancia del calendario mediante miembros privados. Define una vía de acceso pública compatible que funcione cuando el datepicker esté abierto y siga siendo fiable con la interfaz táctil. Se considerará completado cuando los consumidores puedan actualizar el estado del calendario sin depender de miembros privados.
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
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100