Issue #2774💬 AnsweredOpened May 14, 2020by vinceumo0 reactions

MediaCondition: "min-width" breakpoints not applying the correct style in canvas

快速解答by artf

We should apply the same logic from https://github.com/artf/grapesjs/blob/201e1f9a61783080f7be885e9e0be9a40ecc16cc/src/codemanager/model/CssGenerator.js#L151-L162 here https://github.com/artf/grapesjs/blob/201e1f9a61783080f7be885e9e0be9a40ecc16cc/src/csscomposer/view/CssRulesView.js#L122-L129

Read full answer below ↓

Question

Hi,

I'm having some issue with mobile first approach. The canvas render the wrong style when setting different styles at multiple breakpoints. But the code generated is good, this issue only happen in the canvas.

https://codesandbox.io/s/xenodochial-shockley-s02lp?file=/index.js:496-524

const breakpoints = [
  { name: "xs", width: "320px" },
  { name: "xsLg", width: "400px" },
  { name: "sm", width: "630px" },
  { name: "md", width: "740px" },
  { name: "lg", width: "1024px" },
  { name: "xl", width: "1280px" },
  { name: "xxl", width: "1800px" }
];

const editor = grapesjs.init({
  container: "#gjs",
  fromElement: 1,
  storageManager: { type: 0 },
  mediaCondition: "min-width",
  deviceManager: { devices: breakpoints },
  plugins: ["gjs-blocks-basic"]
});

Screenshot 2020-05-14 at 12 49 03

  1. Are you using the latest release (older versions are NOT supported)? Yes using 0.16.12
  2. Are you facing the bug with your local copy of GrapesJS or with the current demo? With my local copy
  3. If a local copy
    1. Indicate all informations about your OS, browser and GrapesJS version.
      MacOs, tried on firefox and Chrome and same issue
  4. What is the expected behavior? Still should change according to the breakpoint in the canvas when using mediaCondition: "min-width"
  5. What happens instead? Style in canvas only apply the change from the 1st breakpoint. but the code in the export view is right. The issue is only in how the canvas render.
  6. If you're able to reproduce the bug indicate all the necessary steps

Thanks a lot for your help

Answers (1)

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...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.