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)
@artf yes! this is not happening if i remove script. the behavior is fine.
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!
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.
Issue #2697
[QUESTION] Problem with custom component type and table cell
Hello! I'm trying to add custom component type: And also I'm adding new block: But when I drop this block on the canvas the <td> tag doesn'...
Issue #2777
[QUESTION] How to update styles in Style Manager
Hello. I created custom component where I set backgraound-image via custom asset manager Custom block code: Command which I run to set new...
Issue #896
[BUG] Media query rules are overridden by class rules in canvas
Hi @artf , I've noticed an issue while testing one of my templates using different device configurations that supposed to trigger media que...
Issue #3579
BUG: RTE misplaced when opened right after dropping `activeOnRender` component
Version: 0.17.4 Are you able to reproduce the bug from the demo?[x] Yes[ ] No Steps to reproduce:Go to the demoDrop a "Text" block inside t...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.