angular / angular/components

feat(MatDatepicker): Expose access to MatCalendar used in MatDatepicker

オープン
#21,462 コメント 8 件 リアクション 6 件 担当者 0 名 GitHub で見る
area: material/datepicker feature P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず MatDatepicker と MatCalendar のエントリポイントを特定し、現在カレンダーインスタンスに private メンバー経由でアクセスしている方法を確認します。datepicker が開いているときに機能し、タッチ UI でも信頼性を維持できる、サポート対象の public なアクセス経路を定義します。consumer が private メンバーに依存せずにカレンダーの状態を更新できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。