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

beforeChange fires for disabled switches #399

Closed
Tazaf opened this issue Mar 16, 2020 · 2 comments · Fixed by #417
Closed

beforeChange fires for disabled switches #399

Tazaf opened this issue Mar 16, 2020 · 2 comments · Fixed by #417

Comments

@Tazaf
Copy link

Tazaf commented Mar 16, 2020

Hi!

First, thanks for this component! It's both complete and flexible 👍

I've stumble upon a behavior that, I think, should not happen. As this issue's title says, the beforeChange observable is subscribed even when the switch is in a disabled state.

That doesn't seem to make much sense, as a disabled switch should be... well... disabled and thus should not trigger any event.

I think this issue is caused by the lack of disabled check in this line:

which probably should be:

  onToggle(event: MouseEvent) {
    if (this.beforeChange && !this.disabled) {
      // ...
    } else {
      this.onClick(event);
    }
  }

I've seen that the onClick method does check for the disabled state, but in my case, it's too late since I'm doing some backend operation in the beforeChange observable ; my http call is made whatever my switch's disabled status is.

(Might be related to #375 and/or #353)

@cmckni3
Copy link
Collaborator

cmckni3 commented Mar 16, 2020

Yeah I don't think it was implemented correctly and I didn't test it (I don't use that functionality). I handle it in my application.

PRs welcome.

@cmckni3
Copy link
Collaborator

cmckni3 commented Aug 7, 2020

Check out 10.0.2

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

Successfully merging a pull request may close this issue.

2 participants