daisyui/react-daisyui

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

https://codesandbox.io/p/sandbox/little-water-vj2zxt

@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

Huh... It should look something like this. I'm not at my pc for a bit though, I'll try get a recording then if it doesn't work for you by then
Screenshot_20230923-191816

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 👀