-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(datepicker): use disabled state from FormControl #7514
Conversation
@@ -147,7 +147,7 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce | |||
|
|||
/** Whether the datepicker-input is disabled. */ | |||
@Input() | |||
get disabled() { return this._disabled; } | |||
get disabled() { return !!this._disabled; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question, is this (and some others in this PR) "coercion" really necessary? Isn't _disabled
already being coerced in set disabled(...)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In most cases the coerceBooleanProperty
would take care of it. Datepicker is a special case because of its cascading disabled state. We need to distinguish between never set and false to make this work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, thanks for explaining :)
@@ -44,39 +45,43 @@ export class MatDatepickerToggle<D> implements OnChanges, OnDestroy { | |||
/** Whether the toggle button is disabled. */ | |||
@Input() | |||
get disabled() { | |||
return this._disabled === undefined ? this.datepicker.disabled : this._disabled; | |||
return this._disabled === undefined ? this.datepicker.disabled : !!this._disabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be this._disabled == null
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either would work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this disabled
is never null
? Because if disabled
is null
this comparison (null === undefined
) won't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coerceBooleanProperty
will make sure its never null. The only reason it can be undefined
is because we don't set an initial value for _disabled
, so if there's no property binding for disabled
the setter is never called and it remains undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mmalerba Rebase? |
f8c5a19
to
450389e
Compare
done |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fixes #6973