angular / angular/components

feat(datepicker): expose the validators that the datepicker uses internally as a public API

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

説明

#### Reproduction

https://stackblitz.com/edit/angular-inex9i?file=app%2Fdatepicker-formats-example.ts

#### Steps to reproduce
1. Add a MatDatePicker to a component and bind it to a Reactive form control
2. Ensure you are reporting the built-in parse error (matDatepickerParse) using mat-error
3. Type in a bad date and see the parse error.
4. Call setValidators() on your reactive form control. It doesn't matter what is sent to setValidators
5. Enter invalid data and you will no longer see matDatepickerParse reported


#### Expected Behavior

Parsing errors after calling setValidators() should continue to report parsing errors

#### Actual Behavior

Parsing errors are no longer reported.

#### Additional Information
The provided DateAdapter (custom or not) is still used. However, since [datepicker-input](https://github.com/angular/components/blob/917a52e03cca1b3568d29094bbf430846ba1c3c9/src/material/datepicker/datepicker-input.ts) will provide a null value if the provided DateAdapter says the inputted date is invalid, you cannot workaround this issue with a custom validator.

Many complex forms may have conditional validation so using setValidators is completely expected.

#### Environment

- Angular: 8.0.0
- CDK/Material: 8.0.1
- Browser(s): Google Chrome 73.0.3683.75 (Official Build) (64-bit)
- Operating System Windows 10 64-bit

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

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

調査の方向性

リンクされた再現手順と src/material/datepicker/datepicker-input.ts から始め、無効な adapter 入力と reactive-form validator の相互作用に注目してください。datepicker の内部 validator が公開 API を通じて利用可能になり、setValidators() の呼び出し後も matDatepickerParse エラーが表示されるようになった時点で、変更は完了です。

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

評価

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

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

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