color-picker icon indicating copy to clipboard operation
color-picker copied to clipboard

Picker not working with numeric only hex values?

Open tehmaestro opened this issue 3 years ago • 1 comments

Hi, it seems that if I have a data-color="#276895" , numeric only hex number, it does not work, and returns black as fallback. Also, is it ok for the "change" event to fire after init? Thanks.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

tehmaestro avatar May 08 '21 15:05 tehmaestro

You can always override the default color parser to make the # part becomes optional because this method is static.

https://github.com/taufik-nurrohman/color-picker/blob/v2.2.4/index.mjs#L444-L465

Example:

let originalColorParser = CP.HEX;
CP.HEX = x => {
    if ('string' === typeof x && '#' !== x[0]) {
        x = '#' + x;
    }
    return originalColorParser(x);
};

Also, is it OK for the "change" event to fire after init?

Any example?

taufik-nurrohman avatar May 09 '21 02:05 taufik-nurrohman