grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

BUG: Select the initial background color doesn't work

Open tranthanhhoa opened this issue 6 years ago • 3 comments

Version: 0.16.18

Bug: Select the initial background color is not working

How to reproduce it: https://imgur.com/xqkt46E

Actually:

  • Component's background does not changes.

Expected:

  • Component's background should change to #000000

Thanks @artf !

tranthanhhoa avatar Jul 29 '20 06:07 tranthanhhoa

@tranthanhhoa I'm not able to reproduce this bug in the demo (same as you), it's working fine here, check this:

bg-color

What did you do before?

RJCAM avatar Jul 29 '20 10:07 RJCAM

Hi @tranthanhhoa & @RJCAM,

The bug indeed only appears when specifically selecting a background color value of #000000.

Tracking it down, it is due to the background-color property's default value of 'none' being set as '' by the color input. It later gets converted to #000000 by the color picker, whereas its actual value is rgba(0, 0, 0, 0) (or transparent).

The updated value is compared to the color picker's stored value on change, & nothing is done if they are equal (hence only failing when setting it to #000000).

I think this should be fixed by setting the background-color property's default value to transparent. Which should also allow to remove the special handling of the none value in the ColorInput.

As always, I'd be happy to open a PR if this looks good to you :).

mcottret avatar Jul 29 '20 16:07 mcottret

background-color property's default value to transparent worked for me. Thank you so much @mcottret !

tranthanhhoa avatar Jul 30 '20 03:07 tranthanhhoa