Swap.onClick fires twice
PolarizedIons opened this issue · 5 comments
Example: Click on the swap element. Look at the count increasing by 2 every time
@PolarizedIons it's working for me from the CodeSandbox you provided with no changes. What are you seeing, do you mind recording?
Here's what I get from the link you sent:
Sep-23-2023.11-28-09.mp4
2023-09-23.20-15-56.mp4
did you manage to replicate it, @benjitrosch ?
@PolarizedIons I was able to reproduce it locally! The issue was due to the way the <Swap>
component is built, using an outer <label>
and an inner <input type="checkbox">
. Basically, the onClick
would fire once for the label and then propagate to the input.
To fix it, I've just re-typed the onClick
(and onChange
) event for the input only. Here's the commit: 6478b1b
Thanks for finding this! Not sure what was going on with the Codesandbox 👀