Skip to content

fix: guard null viewport position in content bounds - #181

Open
dazzatronus wants to merge 1 commit into
mainfrom
fix/null-viewport-position-toolbar
Open

fix: guard null viewport position in content bounds#181
dazzatronus wants to merge 1 commit into
mainfrom
fix/null-viewport-position-toolbar

Conversation

@dazzatronus

Copy link
Copy Markdown
Contributor

Why

getContentBounds used viewportContainer?.position.x, which still throws when position is null. Toolbar rAF updates hit this before the viewport is ready.

Verify

  • Unit: npx jest tests/content-bounds.test.ts
  • Vite e2e: open studio demo → load edit → watch toolbar/selection UI appear without console TypeError on position.x during early frames / before viewport ready.

Risk

Low. Bounds fall back to origin (0) until position exists; same as missing container.

Toolbar positioning reads viewportContainer.position via optional
chaining that stopped at the container. When position is still null
before the viewport is ready, accessing .x/.y threw. Chain through
position so updates no-op safely until the viewport is initialized.
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.

1 participant