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

MdCheckbox fires a click event twice #651

Closed
chrismcgregor opened this issue Jun 8, 2016 · 8 comments
Closed

MdCheckbox fires a click event twice #651

chrismcgregor opened this issue Jun 8, 2016 · 8 comments
Assignees

Comments

@chrismcgregor
Copy link

I noticed that the (click) event is being called twice for MdCheckbox.

@sendilkumarn
Copy link
Contributor

On disable - click function is executed.

@chrismcgregor
Copy link
Author

Sendi,

I get two events for (click) when clicking on a checkbox and it is not disabled. I am now using (change) event, which only fires one event. I have something working now.

By the way, great stuff with Angular2-material.

Cheers!

Chris

Christopher McGregor
415.624.6261 // [email protected]

On Jun 8, 2016, at 3:07 AM, Sendil Kumar N [email protected] wrote:

On disable - click function is executed.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #651 (comment), or mute the thread https://github.com/notifications/unsubscribe/AH_7Vz8UDhgd6s8DuFyqVRLiXIfEqzL3ks5qJpRhgaJpZM4IwiIr.

@webmutation
Copy link

Should the checkbox keep the shadow?
The animation does not seem to complete after the click.

@Neozaru
Copy link

Neozaru commented Jun 9, 2016

Apparently, when registering (click) event on the md-checkbox, the event is handled by the parent element but is also handled by the <input> element when not disabled.
On my side, what does work is parasitizing (click) events ($event.stopPropagation()) on the input itself, and handling it on the top-level element, stopping propagation if disabled.
Note that the (click) event triggered when pressing SPACE key is also blocked when stopping propagation from the <input>.
ngChange behavior remains the same.
Looking for a better solution.

@Neozaru
Copy link

Neozaru commented Jun 10, 2016

@robertmesserle FYI I also worked on it last evening and ended up with an ugly solution. You can still take the unit tests from it (src/components/checkbox/checkbox.spec.ts) : https://github.com/angular/material2/compare/master...Neozaru:bugfixes/checkbox-click-event-once?expand=1

@jelbourn jelbourn changed the title MdCheckbox MdCheckbox fires a click event twice Jun 13, 2016
@robertmesserle
Copy link
Contributor

Closed the wrong thing.

@jelbourn
Copy link
Member

Fixed in #672

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants