Resizing canvas makes componenents end up with wrong positions once exported with dmode 'absolute'
I have sort of found a workaround... Set the .gjs-frame-wrapper to the desired width in CSS and transform: translate (- x px, 0px) for the iframe in CSS. The Canvas is not the correct width then (slightly smaller) but everything seems to work fine nonetheless... I am not going to close the issue however, due to the fa...
Read full answer below βQuestion
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Microsoft edge 98.0.1108.56
Reproducible demo link
https://jsfiddle.net/473b2tah/1/
Describe the bug
The canvas resize is cool but does not take into account that one might be working with px offsets because of dmode which works with px offsets, meaning, the zoomed in canvas, does not reflect the exported index.html page. The entire right side is empty once exported because the images are never told to rescale to fit the exported version. So for example here the canvas is at 0.85 scaling, which means the images should be scaled up by 1.15 and all moved to the right accordingly but are instead stuck on the left, leaving a gap on the right of about 15%. The canvas size should be about 1632 pixels, meanwhile the export width is 15% higher, aka 1920. This is something that I think should be automated and should be fairly simple to implement...
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (3)
I have sort of found a workaround... Set the .gjs-frame-wrapper to the desired width in CSS and transform: translate (- x px, 0px) for the iframe in CSS. The Canvas is not the correct width then (slightly smaller) but everything seems to work fine nonetheless... I am not going to close the issue however, due to the fact, that it's due to the poor implementation of the author, who could fix this extremely easily, as outlined before.
Thanks for reporting this, @Adham380.
The issue with Resizing canvas makes componenents end up with wrong positions once exported with dmode 'absolute' 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 #6695
Prevent default not working for edge
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Edge 144.0.3719.92 Reproducible demo link...
Issue #6562
Moved element snaps to wrong position on resize
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome 138.0.7204.101 Reproducible demo li...
Issue #6348
It's possible to drag and drop literally anything inside grapesjs canvas
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https://grap...
Issue #5607
Cannot expand previously empty layers
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v120.0.6099.199 Reproducible demo l...
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
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
Tutorial
Preset DevFuture 2.0 β New Update Released
Preset continues evolving as a clean, production-ready starting point for building visual editors powered by GrapesJS
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.