-
Notifications
You must be signed in to change notification settings - Fork 68
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
Added the disabled state to the disabled attribute on the native html button #472
base: master
Are you sure you want to change the base?
Added the disabled state to the disabled attribute on the native html button #472
Conversation
This week I had the realization that if someone wants to setup the toggle where you can click to enable it from a disabled state, using the (click) event, this PR change would break that ability. I know that scenario sounds strange, but I had this thought b/c at work we use toggle and in some cases we do allow the user to un-disable the toggle by clicking on it. (not my choice but there are some decent reasons for the setup). So now I'm wondering if this change may not be the best idea. I'm open to anyone else's thoughts. |
Yeah, I was mulling it over. It is a tricky situation. |
Mulled this over a bit. I think the disabled state coming as an input could be managed externally. Maybe, could add another option that adds the disabled attribute when the disabled state is set to true. |
@@ -2,6 +2,7 @@ | |||
type="button" | |||
class="switch" | |||
role="switch" | |||
[disabled]="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.
[disabled]="disabled" | |
[attr.disabled]="disabled ? '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.
I'll give this change a try, but I don't think it works with the disabled attribute. I've had issues in the past where you end up with disabled="false"
in the DOM, and the element is actually 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.
Oh yeah. That's right.
It's due to being an attribute. Luckily, this is a button. It should be disabled="disabled"
when actually disabling or not have the the attribute at all.
See updated suggsetion and let me know if that helps.
Yeah I agree, offering a separate option like |
Yeah kind of wondering if this should:
|
I added the disabled toggle state to the disabled attribute on the native html button. This should help users who use the "onClick" event by not allowing that to trigger when the toggle is set to disabled.
Relates to my initial question and issue here: #353 (comment)