Problem replacing component in absolute dragMode
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
Read full answer below ↓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 #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 #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 #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...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →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.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
🚀 Big Update: Import, Edit & Export Documents with Ease + 14-Day Pro Trial
We’ve just shipped a major update to gjsdocs.com — and it changes how you work with documents
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.