Skip to content

fix(canvas): add maxWidth and safe initial height styles to Canvas. #929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

think-carlo
Copy link

@think-carlo think-carlo commented Mar 7, 2025

I tried to use the Puck component within a legacy Javascript application I work with, and found that when mounting the component the Canvas was broken on the initial render. For some reason the initial side-effects that should appropriately configure zoomConfig weren't throwing and so zoomConfig.rootHeight, i.e. the height of canvas, was set to 0.

Likewise, while the width should have been set to 1280px per my viewport (and was showing as such in the styles within Inspector Tools), it still seemed like the canvas was breaking out of the parent container.

These two changes fixed the issue on my end, and should prevent them from happening for others!

  • By setting the maxWidth to 100% we avoid breaking out of the parent regardless of what we programmatically need to set the width to by viewport.
  • By checking to see if zoomConfig.rootHeight is falsey, we can set it to "auto", in which case it will simply fill its available space on initial render and then re-zoomed on window resize events.

Copy link

vercel bot commented Mar 7, 2025

@think-carlo is attempting to deploy a commit to the Measured Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
puck-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2025 0:59am
puck-docs ✅ Ready (Inspect) Visit Preview Mar 19, 2025 0:59am

Copy link
Member

@chrisvxd chrisvxd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @think-carlo! Unfortunately this breaks the behaviour for me.

Observed behaviour

Canvas is artificially constrained

image

Expected behaviour

Canvas receives the full width

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants