Problem replacing component in absolute dragMode
Question
I have a problem to replace a componente in the same position (top/left), the new component is always added in the positions top: 0px / left: 0px;
I'm triyng something like this:
const selectedComponent = editor.getSelected();
const coll = selectedComponent.collection;
const at = coll.indexOf(selectedComponent);
var styles = selectedComponent.getStyle() || {};
coll.remove(selectedComponent);
let newComponent = coll.add(component, {
fromAddNewComponent: true,
at: at,
});
newComponent .setStyle(styles);
But setStyle() is not working this time...
Answers (1)
The code, more or less, seems ok, be sure to check styles contains the position properties (and the component has also the absolute position). If it's not working yet try to create a reproducible demo, please
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2374
[BUG] Component style is not updated after the drag event in Dragmode('absolute')
In the new dragmode the component's style is not updated after dragging the component. Expected behaviour:Drag element by clicking on the c...
Issue #3211
how to move components
Hello dear: I want move a component to first/end in the wrapper programmatically, i think something like editor.getWrapper().add(editor.sel...
Issue #3185
[QUESTION] How to get the models trait of a component?
Hi there, I added a new type "array" to the TraitManager. So I can add several sub traits. On one point I have to check the traits of the m...
Issue #3059
Header goes on a textbox
Hello, so first thanks to have create GrapesJs this very usefull. I have an issue i add an header on my page and that's the code i add for...
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.