Skip to content
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

disabled attribute questions #353

Open
AlexanderLea opened this issue Jul 16, 2019 · 11 comments
Open

disabled attribute questions #353

AlexanderLea opened this issue Jul 16, 2019 · 11 comments

Comments

@AlexanderLea
Copy link

Hi,

We're using v8.0.1, and have had an issue today where we are setting

[disabled]="componentDisabled"

If we don't set componentDisabled in my component, and don't set a default value, the ngx-ui-switch appears to be defaulting to disabled=true.

The code inside ngx-ui-switch seems to be

@Input() set disabled(v: boolean) {
   this._disabled = v !== false;
 };

which suggests that anything other than explicit false will set disabled=true?

Is this the desired behaviour? - Am I missing something?

Alex

@cmckni3
Copy link
Collaborator

cmckni3 commented Jul 16, 2019

interesting artifact from the original codebase. All of the explicit checks against false should be changed.

@AlexanderLea
Copy link
Author

You accepting PRs?

@cmckni3
Copy link
Collaborator

cmckni3 commented Jul 17, 2019

Yes

@cmckni3
Copy link
Collaborator

cmckni3 commented Feb 25, 2020

I believe reverse is broken as well based on #382.

PRs welcome

@cmckni3
Copy link
Collaborator

cmckni3 commented Jul 30, 2020

The code inside ngx-ui-switch seems to be

@input() set disabled(v: boolean) {
this._disabled = v !== false;
};
which suggests that anything other than explicit false will set disabled=true?

Yes, that's correct but only when disabled is set at all.

      <!-- disabled=true (undefined value passed in) -->
      <ui-switch disabled></ui-switch>
      <!-- explicit disabled=true -->
      <ui-switch checked [disabled]="true"></ui-switch>

      <!-- disabled=false -->
      <ui-switch [disabled]="false"></ui-switch>

      <!-- componentDisabled = undefined => disabled=true -->
      <!-- componentDisabled = null => disabled=true -->
      <ui-switch [disabled]="componentDisabled"></ui-switch>

I am in favor of changing the check.

@cmckni3
Copy link
Collaborator

cmckni3 commented Jul 30, 2020

It's a bit confusing. Maybe use the value that is passed into disabled(v: boolean) as truthy/falsy?

What do you think @AlexanderLea?

@Chewieez
Copy link

Is there a reason that disabling the ui-switch does not add the disabled attribute to the underlying html button element? Not adding it means that if you use the (click)="someMethod()" event with the toggle, it will still fire when clicked, even when disabled, and css cursor: not-allowed.

Changing to use the (change)=someMethod()" does not have that same behavior, but I'm curious if there is a reason the button itself is not being disabled.

@cmckni3
Copy link
Collaborator

cmckni3 commented Jul 30, 2023

Is there a reason that disabling the ui-switch does not add the disabled attribute to the underlying html button element? Not adding it means that if you use the (click)="someMethod()" event with the toggle, it will still fire when clicked, even when disabled, and css cursor: not-allowed.

Changing to use the (change)=someMethod()" does not have that same behavior, but I'm curious if there is a reason the button itself is not being disabled.

Probably just overlooked when initially implemented. Never looked into adding it.

@Chewieez
Copy link

Chewieez commented Aug 1, 2023

Probably just overlooked when initially implemented. Never looked into adding it.

Gotcha. I will look into creating a PR for adding it.

@cmckni3
Copy link
Collaborator

cmckni3 commented Aug 1, 2023

Probably just overlooked when initially implemented. Never looked into adding it.

Gotcha. I will look into creating a PR for adding it.

Sounds good. Thanks!

@cmckni3
Copy link
Collaborator

cmckni3 commented Nov 1, 2023

Found the issue here. Angular can pass the input as string in certain cases. working a fix

Related to #382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants