Loading initial project data from a designer-mode project results in wrong canvas size
I can kinda force it to the correct canvas size by:Not providing projectData in the initial config, Loading the projectData via editor.loadProjectData(...) after initialization and Then running editor.Canvas.getModel().updateDevice(); though it animates from the full width back to device size. It seems that loading th...
Read full answer below ↓Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome v103
Reproducible demo link
https://codesandbox.io/s/laughing-austin-k12mc3?file=/index.js
Describe the bug
If you view the linked CodeSandbox and find the commented out line providing the projectData to the editor, you will see that the canvas gets resized away from the size specified by the device. In a debugger, it seems that updateDim is called multiple times at initialization: the first time with the correct device size and then again with empty width and height which then leads to the gjs-frame-wrapper's sizing getting removed.
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (4)
I can kinda force it to the correct canvas size by:
- Not providing projectData in the initial config,
- Loading the projectData via
editor.loadProjectData(...)after initialization and - Then running
editor.Canvas.getModel().updateDevice();though it animates from the full width back to device size.
It seems that loading the project data happens after the default device is rendered (maybe?) and somehow blows out the current frame, rerendering some default. (I don't know what the default is since I'm only providing a single device config, which appears to be ignored on the second render).
Also, leaving out any one of the three steps above results in the full-width canvas instead of the correct narrow canvas
Thanks @contentfree I'll try to fix that for the next release
Thanks @artf. I'll keep my eye open for the next release (looks like your kanban board is empty now … so should be imminent?)
Thanks for reporting this, @contentfree.
The issue with Loading initial project data from a designer-mode project results in wrong canvas size 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 #3806
Target :null when adding video
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? chrome new version Reproducible demo link...
Issue #6549
Couldnt Resize image
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https://code...
Issue #4497
Updating to GrapesJS v19.5 from v18.4 results in Chrome becoming unresponsive
GrapesJS version[x] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 104.0.5112.79Reproducible demo link h...
Issue #4940
Destroying and re-initializing produces "Cannot read properties of undefined (reading 'get')"
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Google Chrome Version 110.0.5481.100 (Offi...
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
GrapesJS vs Webflow vs Builder.io vs Puck: Which Visual Builder to Choose in 2026
A practitioner's 2026 comparison of GrapesJS, Webflow, Builder.io, and Puck — pricing, AI features, lock-in, and a one-line rule for picking the right one
Tutorial
Big news from DevFuture — we just repriced everything
Hey GrapesJS community 👋 we just repriced all prices on plugins.
Tutorial
Why use grapesjs shadcn for your template builder
Skip months of editor plumbing and start with a fully working visual builder — polished UI included.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.