Skip to content

Commit

Permalink
fix(material): add null check for datepicker errors property
Browse files Browse the repository at this point in the history
fix #3315
  • Loading branch information
aitboudad committed May 27, 2022
1 parent 99b8057 commit 9fcabef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/material/datepicker/src/datepicker.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class FormlyFieldDatepicker extends FieldType implements AfterViewInit, O
// temporary fix for https://github.com/angular/components/issues/16761
if (this.config.getValidatorMessage('matDatepickerParse')) {
wrapProperty(this.field.formControl, 'errors', ({ currentValue }) => {
if (currentValue.required && currentValue.matDatepickerParse) {
if (currentValue && currentValue.required && currentValue.matDatepickerParse) {
const errors = Object.keys(currentValue)
.sort(prop => prop === 'matDatepickerParse' ? -1 : 0)
.reduce((errors, prop) => ({ ...errors, [prop]: currentValue[prop] }), {});
Expand Down

0 comments on commit 9fcabef

Please sign in to comment.