Hello,
When using palettes, the change event behavior is, in my opinion, not consistent.
Let me explain:
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).
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:
"change" event is only triggered when the color is actually selected (you can still listen to the move event to update an element "live").
"change" event is triggered each time the temporary color is changed (including moving on the color pad and when discarding the selection).
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.
Hello, When using palettes, the change event behavior is, in my opinion, not consistent. Let me explain:
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.
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).
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