bgrins / spectrum

The No Hassle JavaScript Colorpicker
https://bgrins.github.io/spectrum/
MIT License
2.32k stars 588 forks source link

"change" event not consistent #482

Open deneb42 opened 7 years ago

deneb42 commented 7 years ago

Hello, When using palettes, the change event behavior is, in my opinion, not consistent. Let me explain:

  1. When moving the color, the change event is not triggered. When you use the palette to directly select a color, the change event is triggered.

    Why is it triggered in one case and not the other ?

Moreover why is this event triggered when the value is still being edited (I'm not that familiar with the expected "change" event behavior, if this is the expected behavior, then it makes sense).

  1. When you cancel the edition, the color is set back to the previous value, but no "change" event is triggered. If you previously used the "change" event to manipulate an element's color, you can't set it back to the original value without using spectrum's own event (not practical when you want to stay color picker agnostic).

I believe you should stick to either:

ps: if you want to reproduce the behavior, you can use the doc's websites:

https://bgrins.github.io/spectrum/ The first color picker at the top has the expected behavior (and relies on spectrum, move and hide events, not on the "change" event).

https://bgrins.github.io/spectrum/#options-showPalette The palette demonstration color picker uses the "change" event and illustrates the event's incoherency: Try to click on a palette element and then cancel: the doc's border has been updated even if the edition was canceled.

Thanks for your attention, don't hesitate if you need more info.

Cheers, Benjamin

claudiomedina commented 7 years ago

@bgrins , is there any solution for this?

claudiomedina commented 7 years ago

I see the bug was fixed on master branch. Still, the CDN's latest version (1.8.0) is behind this fix. When will this be available?