Problem with copy and paste a node
I've tried locally but the node is placed correctly. Are you able to create a live demo, please?
Read full answer below ↓Question
**Version:0.16.27
Are you able to reproduce the bug from the demo?
[ * ] Yes [ ] No
What is the expected behavior? In the right panel and canvas, the pasted node should be after the copied node.
What is the current behavior?
I copy a node. In the views-container(right panel), the pasted node is after the copied node. But in the canvas, the pasted node is before the copied node. As shown below:

Describe the bug detailed
This bug occurs when there are spaces or carriage returns between html tags.
Because in the ‘grapesjs/src/dom_components/view/ComponentsView.js’,addToCollection Method uses js childNodes to get the child nodes.

In the Chrome browser, in addition to the complete label as a node, the content between the ending character ">" of one label and the starting character "<" of the next label (except comments, including any text, Spaces, carriage returns, tabs) are also considered a node.
Are you able to attach screenshots, screencasts or a live demo? bug.mov.zip
Can sombody help with this? Thank you very much!
Answers (4)
I've tried locally but the node is placed correctly. Are you able to create a live demo, please?
Sorry, I did not elaborate on the scenario where this error occurred. The components that come with grapesjs do not produce this error, because they don‘t have spaces,carriage returns or tabs. I found this problem while customizing components. I have customized a lot of my own components, and some of them will have this situation. An example of the initialization of the custom component node that found this problem is as follows.
viewTemplate() {
return '
<form data-gjs-type="form-panel" class="form-panel">
</form>
'
},
...
onViewInit() {
const comps = this.model.get('components');
if (!comps.length) {
comps.reset();
comps.add('
<div class="form-panel-group" data-gjs-type="form-panel-group"><label class="label">多/单选:</label><div data-gjs-type="select-comp" class="select-comp"></div></div>
<div class="form-panel-group" data-gjs-type="form-panel-group"><label class="label">多选选择:</label><div data-gjs-type="mdc-checkbox-group" class="mdc-checkbox-group"></div></div>
</div>
')
}
...
}
If you want to reproduce this problem in the grapesjs default component, you can enter a space between nodes through the “Editor as HTML” of the f12 Elements . as follows.

@artf I accidentally closed the issue.
Thanks for reporting this, @nanaya1.
The issue with Problem with copy and paste a node appears to be a race condition or state management timing problem. This typically happens when component lifecycle events and DOM modifications overlap, creating an inconsistent state.
What to try:
- Add a setTimeout wrapper to ensure the DOM has settled:
setTimeout(() => {
// your operation here
}, 0);
-
Check initialization order — make sure components are fully loaded before you interact with them
-
Use the editor's event system — listen to completion events:
editor.on('component:mount', (component) => {
// safe to interact with component here
});
Recommended next steps:
- Test with the latest GrapesJS version if you haven't
- Provide a minimal reproducible example (CodeSandbox) — this helps the team identify the root cause faster
- Include GrapesJS version, browser, and console errors in your report
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3295
BUG (v0.16.41): Button component with draggable property is not working properly
Version: v0.16.41 Are you able to reproduce the bug from the demo? [ ] Yes [ ] No What is the expected behavior? When we have a button with...
Issue #3579
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...
Issue #3131
Paste as plain text into Text component adds <font /> wrapper to pasted text
Version: 0.16.27 Are you able to reproduce the bug from the demo? [] Yes [X] No What is the expected behavior? Paste as plain text (text no...
Issue #3655
The form button name changes are not getting captured in generated html code
Version: Version 0.17.19(grapesjs) Version 0.1.11(grapesjs-preset-webpage) Are you able to reproduce the bug from the demo?[ ] No What is t...
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
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
GrapesJS vs Webflow vs Tilda: What to Choose for Your Business in 2026
Choosing the right website platform in 2026 is no longer just about building a site
Tutorial
GJS Market 2.0 - Donations, Tracking, Labels and Better Product Discovery
We’ve rolled out a new set of GrapesJS marketplace updates across GJS Market, focused on improving how creators distribute products
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.