GrapesJS / preset-webpage

GrapesJS Plugin Webpage Preset
http://grapesjs.com/demo.html
BSD 3-Clause "New" or "Revised" License
335 stars 291 forks source link

Background color doesn't effectively change when removing value #42

Closed barryross closed 2 years ago

barryross commented 4 years ago

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})
        }
      });
    });
artf commented 2 years ago

Closing as it doesn't appear to be an issue anymore with the latest versions