Issue #2359Opened October 30, 2019by sheldon5forever1 reactions

Absolute mode, component's style missing when dragged into canvas

Question

Hi guys, I'm working with grapesjs which version is '0.15.8', and in 'absolute' mode when I drag a block into canvas, I find the styles of component are missing.

Define component as following:

domc.addType(lineChartRef, {
    model: defaultModel.extend({
      defaults: {
        ...defaultModel.prototype.defaults,
        name: lineChartRef,
        resizable: true,
        dmode: 'absolute',
        childrenSelectable: false,
        highlightable: false,
        droppable: false,
        style: { "width": "700px", "height": "500px" },
        traits: [...],
        ...
        script() {
          ...
        }
     }
  })
})

And I found the code in Droppable here: /utils/Droppable.js@L78

const { left, top, position } = target.getStyle();
comp.setStyle({ left, top, position });

the component's styles are replaced. Should 'addStyle' be used here instead of 'setStyle'?

Answers (3)

pouyamiralayiOctober 31, 20191 reactions

@artf yes! this is not happening if i remove script. the behavior is fine.

pouyamiralayiOctober 30, 20190 reactions

Hi @sheldonwr this bug you are referring to is not reproducible in my side, here i tried your type definition on the demo and it is working, please check the below code and see what is missing in your side:

domc.addType('lineChartRef', {
    model: {
      defaults: {
      tagName:'p',
        content:'some random text',
        resizable: true,
        dmode: 'absolute',
        childrenSelectable: false,
        highlightable: false,
        droppable: false,
        style: { "background":'red',"width": "700px", "height": "500px" },
        script() {
        }
     }
  }
})
bm.add("testLine",{
label:'lineChartRef',
  content:{
  type:'lineChartRef'
  }
})

the issue i observed with this component was that when i move it around, the component stops rendering children and freeze with no respond to any interaction. this might be a bug by specifying component level drag mode instead of global. @artf cheers!

artfOctober 31, 20190 reactions

Ok, actually a weird thing happens when a component has script property defined... Thanks for the report guys, I'll check this out. Can you confirm that without script it behaves correctly?

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.