-
Notifications
You must be signed in to change notification settings - Fork 905
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: added formDisabledCallback for formAssociated elements #5053
Conversation
Right now Radio and Slider are disabled inside disabled Also beside using a variable to track |
|
||
/** @private */ | ||
formDisabledCallback(formDisabled: boolean) { | ||
this.formDisabled = formDisabled; |
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.
I don't think we need this property. You should be able to set this.disabled = formDisabled
, which should also handle updating the UI correctly. Can you try that?
You also won't need this.requestUpdate()
when setting this.disabled
, since it's a @property
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.
I planned to do that but it would be a wrong behavior. If you set disabled
of the control at formDisabledCallback
, the control itself would be disabled.
So in case you have a fieldset
with two controls, one is disabled (by itself) and one is not, when the fieldset disabled
is lifted, one control should still be disabled:
<fieldset>
<input disabled /> <!-- This should stay disabled if the fieldset is disabled and then enabled -->
<button></button>
</fieldset>
Also standard elements (like input
) still has its disabled
property being false
even when it's disabled by its parent. That's why I used an extra variable to keep track of the state. An alternative should be using .matches(":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.
Gotcha, thanks for the explanation!
FYI on this, we're working on mixin behaviors for shared functionality, including form associated mixins. We may hold off on this PR for a bit while that's in development |
@asyncLiz Yes no problem, when making this change I also thought this should be a common behavior for all controls that are formAssociated and should inherit from a common ancestor/mixin. I will close this PR for now then. |
Controls should be disabled when a parent
fieldset
hasdisabled=true
. Fix #5049