Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sheldon5forever opened this issue Oct 30, 2019 · 4 comments
Closed
Labels

Comments

@sheldon5forever
Copy link

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'?

@pouyamiralayi
Copy link

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!

@artf
Copy link
Member

artf commented Oct 30, 2019

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?

@artf artf added the bug label Oct 30, 2019
@artf artf closed this as completed in 5217407 Oct 30, 2019
@pouyamiralayi
Copy link

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

@sdrebel
Copy link

sdrebel commented Nov 18, 2019

In my custom component script is not there but still I have the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants