feat(datepicker): expose the validators that the datepicker uses internally as a public API
- Ngôn ngữ chính
- TypeScript
- Star
- 25k
- Fork
- 6.8k
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 91
Mô tả
#### 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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với reproduction được liên kết và src/material/datepicker/datepicker-input.ts, tập trung vào cách input không hợp lệ của adapter tương tác với các validator của reactive form. Thay đổi được hoàn tất khi các validator nội bộ của datepicker có thể được truy cập thông qua một API công khai và các lỗi matDatepickerParse vẫn xuất hiện sau khi gọi setValidators().
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- angular, typescript
- Lĩnh vực
- frontend
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100