Issue #2586Opened February 19, 2020by liudmyla-schastlyvets0 reactions

[Question]: How update style manager panel using few devices and custom css class

Question

There is a custom class added to simple grapesjs project:

editor.StyleManager.addProperty('settings', {
     name: 'Size*',
     property: 'font-size',
     type: 'select',
     options: [
        { name: 'default', value:'1.5rem'},
        { name: 'small', value:'1rem'},
        { name: 'large', value:'2rem'}],
        defaults: '1.5rem',
   });
const cc = editor.CssComposer;
cc.setRule('.class', { 'font-size': '2rem' });

If there is no devices and user adds the class into the selectors field Settings sector is updated its font-size property correctly.

<img width="1440" alt="Screen Shot 2020-02-19 at 2 33 50 AM" src="https://user-images.githubusercontent.com/32596493/74790527-7b0efe00-52c0-11ea-9999-a98fa654de56.png">

If there are few devices (one of them set like)

        editor.setDevice('Tablet')

and user adds the class into selectors field Settings sector isn't updated its font-size property correctly.

<img width="1438" alt="Screen Shot 2020-02-19 at 2 40 29 AM" src="https://user-images.githubusercontent.com/32596493/74790751-3cc60e80-52c1-11ea-8fb7-fdaf5ef2b5ff.png">

Could you please help me to solve this problem?

Answers (2)

artfFebruary 25, 20200 reactions

Unfortunately, this is due to how getComputedStyle works, which returns resolved values, so by using rem instead of px "confuses" the value. At the moment I don't have any plan on fixing this issue but I'd really appreciate a PR or at least an idea on how to solve this

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.