grapesjs-preset-webpage icon indicating copy to clipboard operation
grapesjs-preset-webpage copied to clipboard

Background color doesn't effectively change when removing value

Open barryross opened this issue 4 years ago • 0 comments

When removing a value from the background-color property and pressing enter , the color doesn't effectively get removed.

A workaround is to listen for changes to the background color property, and bind a transparent value to the model

this.editor.on('component:styleUpdate:background-color', (model) => {
        const updateToBg = this.editor.StyleManager.getProperty('background_&_border', 'background-color').attributes.value;
        let s = model.getStyle()

        if (!updateToBg) {
          model.setStyle({...s, 'background-color':'transparent'});
        }else{
          model.setStyle({...s, 'background-color':updateToBg})
        }
      });
    });

barryross avatar Apr 08 '20 13:04 barryross