Skip to content

Commit 7367823

Browse files
authored
fix(material/datepicker): pass correct inject flags to injector (#22665)
We have a call to `Injector.get` in the date range input which is supposed to fall back to `null` if the value doesn't resolve, however we're missing the `Optional` flag. It works by accident at the moment, because the inject flags aren't actually being passed through by the framework. angular/angular#41592 is supposed to fix the framework issue, but their CI will break due to our usage. These changes fix our usage in order to unblock the framework PR.
1 parent 3027f8c commit 7367823

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/material/datepicker/date-range-input-parts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ abstract class MatDateRangeInputPartBase<D>
102102
// itself. Usually we can work around it for the CVA, but there's no API to do it for the
103103
// validator. We work around it here by injecting the `NgControl` in `ngOnInit`, after
104104
// everything has been resolved.
105-
const ngControl = this._injector.get(NgControl, null, InjectFlags.Self);
105+
// tslint:disable-next-line:no-bitwise
106+
const ngControl = this._injector.get(NgControl, null, InjectFlags.Self | InjectFlags.Optional);
106107

107108
if (ngControl) {
108109
this.ngControl = ngControl;

0 commit comments

Comments
 (0)