Automattic / Iris

A(n awesome) Color Picker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clear colour does not trigger change event

mattheu opened this issue · comments

If I have already set the colour, but I want to remove it later, I cannot as it does not trigger a change event.

Related to #53

Has there been any development with this? I'm using 2 pickers to create a background gradient. When a color is chosen in either of the pickers the change callback gets the values of the 2 pickers to create a linear-gradient css rule. It all works fine until you try to clear either of them. Obviously the change callback is not fired. Just wondering if anyone has manage to find a work around?

2021 and still nothing on this?

Here's a hack for the time being.

var added_clearer = false;
$('.color-field').wpColorPicker({
    change: function(){
        if ( ! added_clearer ) {
            $('.wp-picker-clear').on('click', function(){
                $(this).parent('.wp-picker-input-wrap').find('.color-field').change();
            });
            added_clearer = true;
        }
    }
});