uiwjs / react-color

🎨 Is a tiny color picker widget component for React apps.
https://uiwjs.github.io/react-color
MIT License
274 stars 92 forks source link

Sometimes Wheel don't react to onChange #134

Closed spl1nt3r99 closed 9 months ago

spl1nt3r99 commented 9 months ago

I've used code like this:

const [hsva, setHsva] = useState({ h: 214, s: 43, v: 90, a: 1 })

const onChangeColorPicker = (event: any) => {
    setHsva({ ...hsva, ...event.hsva })
  }

return (
 <Wheel className={"wheel"} color={hsva} onChange={(event) => onChangeColorPicker(event)} />
)

At times, when I simply click (not click, hold, and move) on the wheel, the color doesn't update immediately. I find that I have to click on the same spot again to trigger the onChange event. Do I need to use another approach?

jaywcjlove commented 9 months ago
image

@spl1nt3r99 I can't reproduce the problem you describe.

You can give me an example that can be reproduced

spl1nt3r99 commented 9 months ago

@jaywcjlove I've simplified code for issue, original was:

const onChangeColorPicker = (event: any) => {
    setHsva({ ...hsva, ...event.hsva })
    dispatch(updateTemporaryApplicationColorScheme(hsvaToHex(hsva)))
}

Change it to and it works as expected:

const onChangeColorPicker = (event: any) => {
    setHsva({ ...hsva, ...event.hsva })
    dispatch(updateTemporaryApplicationColorScheme(hsvaToHex(event.hsva)))
}

I suppose we can close this issue, because it's not relative to wheel, but react. Thank you for the quick response.