jpuri / draftjs-utils

An collection of useful utility functions for DraftJS.
MIT License
286 stars 47 forks source link

Background color toggle #18

Closed Vladislao closed 4 years ago

Vladislao commented 5 years ago

Hello @jpuri, thank you for such a great tool.

It looks like background color toggle doesn't work properly. You can specify background color, but can't toggle it back by clicking on the same color (the way it works with text color).

It might be caused by this line: https://github.com/jpuri/draftjs-utils/blob/master/js/inline.js#L211

    const styleKey = styleType === 'bgcolor' ? 'backgroundColor' : styleType;
    if (!currentStyle.has(`${styleKey}-${style}`)) {

currentStyle contains bgcolor-rgb(...), but not the backgroundColor-rgb(...), might be a typo?

Reproducible on https://jpuri.github.io/react-draft-wysiwyg/#/ https://youtu.be/WJDcKKTH89E

MamorukunBE commented 2 years ago

I've personnally solved that by adding a "transparent color" to the list displayed to the user :)