Issue #1978Opened April 25, 2019by 3dmedium0 reactions

[Bug]: Styles allways applied to classes

Question

Hello,

I have a Problem with styling individual Items.

The following html Code:

<div class="ddm-flex-cols">
      <div class="ddm-flex-cols-element">
          This is some Text
        </div>
      <div id="icbp" class="ddm-flex-cols-element">
        Text
      </div>
    </div>
    
<style>


.ddm-flex-cols {
    display: flex;
    flex-direction: row;
    margin: -16px;
    padding: 16px 0px;
    flex-wrap: wrap;
}


.ddm-flex-cols-element {
    flex-grow: 2;
    margin: 16px;
    flex-shrink: 0;
    flex-basis: 0;
}

#icbp {
	max-width:300px;
}
</style>

Loads fine. But when I Click the Component with "#icbp" then the class .ddm-flex-cols-element will get the style max-width. Setting this.el.style while rendering the Object is also Integrated to the CSS (Id only) the Docs tell changes to this.el will not being saved to Components.

Reproduction with DEMO is not possible for me because its only happening with some loaded canvas styles. I'm using version 0.14.57 My Config for reproduction:

let options = {
    container: '#gjs-content-editor',
    protectedCss: '',
    style: '',
    canvas: { styles: ['/some/file.css'] },
  };

Answers (3)

artfMay 1, 20190 reactions

Can you please try to add this to your options avoidInlineStyle: true and let me know

3dmediumMay 1, 20190 reactions

Hi @artf , Yes I tried this, still no luck. I had the time to minimize this issue to a codesandbox:

https://codesandbox.io/embed/jnplq7op55

Position of the protectedCss Content can be varied put it to style or in a file and load it by cvanvas.style the behavior keeps the same.

The Issue is gone by deactivationg selectors before adding components:

editor.on('selector:add', selector => selector.set({ 
	active: false, // disable the selector
	// or
	private: true, // hide the selector
}));

from #1979 (both versions work) for me this is a solutuion but I think in some cases it might not.

Best regards

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.