Issue #986Opened March 29, 2018by nojacko2 reactions

[BUG]: Exported CSS cannot override body's background-color

Question

When a body background style is defined in the style option of the init function it's not possible to override.

Given the style:

body {
    background-color: #000000;
}

After changing the background-color in Grapes, the CSS output is:

body {
    background-color:#f80000; /* Colour selected in Grapes */ 
}
body {
    background-color:rgb(0, 0, 0); /* Original colour that should be overwritten */
}

Due to the ordering, the original colour will take precedence when used.

While not necessarily an issue, the repetition of body isn't needed and would probably solve this issue if the body css definition was merged. I believe this happens with other CSS selectors too.

Steps to reproduce

  1. https://jsfiddle.net/jk3g2eu2/
  2. Click the wrapper in the canvas
  3. Change background color.
  4. Click the code icon to see generated CSS.

Answers (2)

artfMarch 31, 20182 reactions

Thanks James, we already aware of it #552 but unfortunately not yet provided any fix :/ The main problem is that GrapesJS doesn't handle well body/wrapper styling and so, as a result, we have the body coming from 3 different spots:

  • from protectedCss option
  • from the wrapper's component style (which usually is the body and so I handle it separately)
  • and like in your case, also from another CSSRule (created by style: 'body{background-color:#000000;}') We need to find a correct way to handle all these cases but I didn't yet find time to look at it, so I'd appreciate any advice/help. I close this and suggest you subscribe to #552 if you want any further updates.
lock[bot]September 17, 20190 reactions

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.