Automattic / Iris

A(n awesome) Color Picker
GNU General Public License v2.0
259 stars 67 forks source link

Clear colour does not trigger change event #57

Open mattheu opened 8 years ago

mattheu commented 8 years ago

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 https://github.com/Automattic/Iris/issues/53

NRDay commented 6 years ago

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?

vinnyusestrict commented 3 years ago

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;
        }
    }
});