Dragging multiple blocks reverses the order
Hello I'm trying to fix this bug This is more of an exercise for me to dive in grapesjs code, let me know if I'm loosing my time or if it sounds useful
Read full answer below βQuestion
Version:
0.17.4
Are you able to reproduce the bug from the demo?
YES
What is the expected behavior?
When dragging the blocks, the order should be preserved.
What is the current behavior?
When dragging to the top or above the set of blocks, it goes in one order.
When dragging to the bottom or below the set of blocks, it goes in another order.
This may become a problem if selecting a lot of blocks or the blocks are tall.
Are you able to attach screenshots, screencasts or a live demo?


https://user-images.githubusercontent.com/676680/122304455-5f217800-cf59-11eb-8925-0374deb9b1fb.mov
Answers (2)
Hello I'm trying to fix this bug This is more of an exercise for me to dive in grapesjs code, let me know if I'm loosing my time or if it sounds useful
Thanks for reporting this, @japo32.
The issue with Dragging multiple blocks reverses the order 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 #3305
(v0.16.41) Button not set as active on click
Version: v0.16.41 Are you able to reproduce the bug from the demo? [ ] Yes [x] No What is the expected behavior? When I click on a button,...
Issue #3301
Change one copied element affects other copied elements
Version:0.16.41 Are you able to reproduce the bug from the demo? Yes What is the expected behavior? When I'm copying/pasting elements (e.g....
Issue #3681
Textable not working with extended text component
Version: 0.17.22 Are you able to reproduce the bug from the demo?[X] Yes[ ] No What is the expected behavior? Should be able to drop a text...
Issue #3352
Default Content is getting Inserted while using setComponents if Tag Body is empty
Version: Latest You can get the version by typing grapesjs.version into the console Are you able to reproduce the bug from the demo?[X] Yes...
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 βBrowse Plugin Categories
Jump directly to plugin category pages on the marketplace.