Layer panel: drag and drop makes items disappear (firefox and chrome)
I can confirm I’m seeing the same issue, and it’s caused by the disappearing element having a computed height of 0px (because it’s using display: none). While this is definitely a bug, as a temporary workaround you can avoid using display: none on that node inside the editor and use an "equivalent" hiding style that k...
Read full answer below ↓Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Firefox 137.0 and Chrome 136.0.7103.92
Reproducible demo link
https://grapesjs.com/demo.html
Describe the bug
How to reproduce the bug?
- Open the official demo https://grapesjs.com/demo.html
- To reproduce the exact same structure, paste this JSON in localStorage >
gjsProject:
{"assets":[],"styles":[{"selectors":["#ixix"],"style":{"padding":"10px"}},{"selectors":["#ilfp"],"style":{"background-color":"#e7e7e7","padding":"20px"}},{"selectors":["#ivgby"],"style":{"padding":"10px"}},{"selectors":["menu"],"style":{"display":"flex"}},{"selectors":["nav__burger"],"style":{"display":"none"}},{"selectors":["nav_check"],"style":{"display":"none"}},{"selectors":["#ilpnl"],"style":{"padding":"10px"}},{"selectors":["nav"],"style":{"display":"flex","justify-content":"space-between"}},{"selectors":["nav__burger"],"style":{"display":"block"},"mediaText":"(max-width: 992px)","atRuleType":"media"},{"selectors":["menu"],"style":{"background-color":"#e7e7e7","display":"none","flex-direction":"column","padding":"40px","position":"absolute","right":"0px","top":"80px"},"mediaText":"(max-width: 992px)","atRuleType":"media"},{"selectors":[],"selectorsAdd":".nav_check + .menu","style":{"display":"flex"},"mediaText":"(max-width: 992px)","atRuleType":"media","atRule":"media"}],"pages":[{"frames":[{"component":{"type":"wrapper","stylable":["background","background-color","background-image","background-repeat","background-attachment","background-position","background-size"],"attributes":{"id":"i9x1"},"components":[{"tagName":"NAV","type":"container","classes":["nav"],"attributes":{"id":"ilfp"},"components":[{"type":"checkbox","void":true,"classes":["nav_check"],"attributes":{"type":"checkbox","id":"check"},"selector":{"mainSelector":{"pseudoClass":null,"selectors":[{"active":true,"type":"id","value":"check"},{"active":true,"type":"class","value":"nav_check"}]}}},{"type":"text","attributes":{"id":"ilpnl"},"components":[{"type":"textnode","content":"Logo","attributes":{"id":"itilh"}}],"custom-name":"Logo"},{"type":"container","classes":["menu"],"attributes":{"id":"i9568"},"components":[{"type":"text","classes":["item"],"attributes":{"id":"ixix"},"components":[{"type":"textnode","content":"Afriaca","attributes":{"id":"ihp2j"}}],"custom-name":"Items","id-plugin-data-source":"ixix-5417","privateStates":[{"expression":[{"dataSourceId":"ds-1","fieldId":"continents","kind":"list","label":"continents","options":{"filter":"{}"},"previewIndex":0,"propType":"field","type":"property","typeIds":["Continent"]}],"id":"__data"},{"expression":[{"componentId":"ixix-5417","exposed":false,"forceKind":"object","label":"Loop data (Continent)","previewIndex":0,"storedStateId":"__data","type":"state"},{"dataSourceId":"ds-1","fieldId":"name","kind":"scalar","label":"name","options":{},"previewIndex":0,"propType":"field","type":"property","typeIds":["String"]}],"id":"innerHTML"}],"selector":{"mainSelector":{"pseudoClass":null,"selectors":[{"active":true,"type":"id","value":"ixix"},{"active":true,"type":"class","value":"item"}]}}}],"custom-name":"Menu","selector":{"atRule":"@media (max-width: 992px)","mainSelector":{"pseudoClass":null,"selectors":[{"active":false,"type":"id","value":"i9568"},{"active":true,"type":"class","value":"menu"}]},"operator":{"displayName":"adjacent to","hasParam":false,"helpLink":"https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator","isCombinator":true,"sentencePre":"When it is","stringRepresentation":" + ","type":"+"},"relatedSelector":{"selectors":[{"active":true,"type":"class","value":"nav_check"}]}}},{"tagName":"LABEL","type":"text","classes":["nav__burger"],"attributes":{"for":"check","id":"ivgby"},"components":[{"type":"textnode","content":"☰","attributes":{"id":"iwbgb"}}],"custom-name":"Button","originalTagName":"div","selector":{"mainSelector":{"pseudoClass":null,"selectors":[{"active":true,"type":"id","value":"ivgby"},{"active":true,"type":"class","value":"nav__burger"}]}}}],"custom-name":"Nav","selector":{"mainSelector":{"pseudoClass":null,"selectors":[{"active":false,"type":"id","value":"ilfp"},{"active":true,"type":"class","value":"nav"}]}}}],"head":{"type":"head","attributes":{"id":"iz3t-2"}},"docEl":{"tagName":"html","attributes":{"id":"iaea-2"}},"COMPONENT_NAME_PREFIX":"","publicStates":[]},"id":"hqYccTexwziqC7Cq"}],"id":"ngEtsfeqULJzmyUR"}],"symbols":[],"settings":{"head":""},"fonts":[],"publication":{},"pagesFolder":"pages"}
- Open the Layers panel
- Drag the layer named "Checkbox" and drop it below "Logo"
- Observe the canvas and the layers list
What is the expected behavior?
The dragged layer moves to the new position
What is the current behavior?
- The dragged layer stays in its original position
- The component "Button" disappears from the canvas and from the layers
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (2)
I can confirm I’m seeing the same issue, and it’s caused by the disappearing element having a computed height of 0px (because it’s using display: none).
While this is definitely a bug, as a temporary workaround you can avoid using display: none on that node inside the editor and use an "equivalent" hiding style that keeps the element in the layout but invisible, e.g. visibility: hidden; pointer-events: none; height: 1px (the 1px height is what actually keeps the element in the editor after the sort operation).
This is obviously just a workaround until the underlying issue is fixed.
Thanks for reporting this, @lexoyo.
Great question about Layer panel: drag and drop makes items disappear (firefox and chrome). The recommended approach with StyleManager is to use the event-driven API.
Start here:
- Check the GrapesJS documentation for your specific module
- Look for the
on()event listener method - Most operations can be achieved by listening to editor and component events
Common patterns:
// Listen for changes
editor.on('change', () => console.log('something changed'));
// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));
If you're still stuck:
- Share a minimal CodeSandbox reproduction
- Include what you've already tried
- Mention your GrapesJS version
- The community is here to help!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5086
Style:property:update and Property onChange trigger excessively
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Version 112.0.5615.137 (Official Bu...
Issue #6685
Custom component styles are not applied after deletion and re-addition
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v143.0.7499.193 Reproducible demo l...
Issue #5274
Parser bug inside Remix
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v114 Reproducible demo link https:/...
Issue #5229
textnode with content "null" is rendered as "null" not whitespace
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome Version 114.0.5735.199 (Official Buil...
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.