-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix(checkbox, radio): click event is triggered once #27508
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
Conversation
|
// to the checkbox, which means when the label is clicked, the | ||
// checkbox receives this event. To prevent a duplicate click event, | ||
// we need to stop the event from bubbling. | ||
ev.stopPropagation(); |
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.
Does pointer-events: none
on the native element work here too? We fixed a similar bug in toggle a couple years ago: #23146
I'd prefer a CSS-only approach rather than adding even more JS.
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.
pointer-events: none
on the inner input
control continues to result in duplicate clicks. The problem is the label invokes a click event on the input
and does not take into consideration the pointer events.
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'm fine with the changes, but do we know why this does not happen with ion-toggle
?
ade4229
to
37c9508
Compare
Removed the tests that I originally introduced. This issue does not reproduce outside of a browser environment (an emulated environment does not result in 2x events). This issue is not present in |
@mapsandapps I'm adding you for a review as well, if you have availability before end of sprint. I wasn't able to take advantage of the same |
Closing as per #27506 (comment) |
@liamdebeasi Was this PR supposed to be closed too? |
Whoops yes. Thanks! |
Issue number: Resolves #27506
What is the current behavior?
Modern form controls (
ion-radio
,ion-checkbox
) that associate a label to an input result in an additional click event, when the label is clicked.e.g.:
When the host is clicked, the label is the click target. When a label is associated to an input, it will trigger a click event on the control/input. This causes the event to bubble and a duplicate click event to fire.
What is the new behavior?
ion-checkbox
andion-radio
ion-checkbox
andion-radio
Does this introduce a breaking change?
Other information
Dev-build:
7.0.8-dev.11684439870.1ade4229