-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: ion-checkbox fires onclick twice #27506
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
Comments
Here's a vanilla reproduction as well: https://stackblitz.com/edit/jd93fs?file=index.html |
Hello @corysmc thanks for reporting this issue! I can reproduce it with both e.g.: <my-component>
#shadow-root
<label>
<input />
</label>
</my-component> The |
Here is a dev-build to test with: Forked reproduction with the dev-build: https://stackblitz.com/edit/8t9ymz-6biavu?file=package.json |
Awesome, thanks @sean-perkins ! |
Note that I had to upgrade ionic version to a dev nightly build because of bug on ion-checkbox triggering @click twice see: ionic-team/ionic-framework#27506
There is some confusion around event retargeting: ionic-team/ionic-framework#27506. I added docs on how events work in Ionic.
Hi everyone, I discussed this with the team, and we have determined this is not a bug in Ionic. This behavior is happening because the click event is being retargeted as it moves from the Shadow DOM to the Light DOM. In the case of You can see this here: https://codepen.io/liamdebeasi/pen/OJaPqpR There appears to be duplicate click events, but calling composedPath() reveals that the click events are coming from two separate elements. We have decided not to suppress this behavior because it would mean suppressing what the browser is designed to do. While you can use I am going to close this, but let me know if there are any questions. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
v7.x
Current Behavior
If an ion-checkbox has an onClick listener - it will fire onClick twice
Expected Behavior
Should only fire onClick once when you click the checkbox.
Steps to Reproduce
Code Reproduction URL
https://stackblitz.com/edit/8t9ymz?file=src%2Fmain.tsx
Ionic Info
See stackblitz repro above - not using ionic CLI
Additional Information
Maybe related - not sure: #27492
The text was updated successfully, but these errors were encountered: