Skip to content

Fix viewport jump when placing first room on blank map#1

Merged
adamrdrew merged 1 commit into
masterfrom
claude-support
Jan 27, 2026
Merged

Fix viewport jump when placing first room on blank map#1
adamrdrew merged 1 commit into
masterfrom
claude-support

Conversation

@adamrdrew

@adamrdrew adamrdrew commented Jan 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes viewport jumping unexpectedly when placing the first room on a blank map
  • Makes mapOrigin stable within a map session (only updates when map file changes)
  • Sets initial scale guard for blank maps to prevent auto-zoom on first geometry

Root Cause

Two interacting issues caused the viewport to jump:

  1. Dynamic mapOrigin: The coordinate system origin was recalculated every time map content changed, shifting render coordinates
  2. Missing guard for blank maps: The initial scale effect triggered auto-zoom when mapBounds went from null to valid

Test plan

  • Create a new blank map
  • Select the room tool and place a room — viewport should not move
  • Place additional rooms — no jumping should occur
  • Open an existing map with geometry — initial fit-to-bounds should still work

🤖 Generated with Claude Code

The viewport was jumping unexpectedly when placing the first room on a
blank map due to two interacting issues:

1. The mapOrigin (center of bounds used for coordinate centering) was
   recalculated every time map content changed. When the first room was
   added, mapOrigin shifted from (0,0) to the room's center, causing all
   render coordinates to shift while the view offset stayed the same.

2. The initial scale effect's guard ref was not set for blank maps, so
   when mapBounds transitioned from null to valid, auto-zoom triggered
   unexpectedly.

Fixed by:
- Making mapOrigin stable within a map session (only updates when the
  map file changes, not when content is edited)
- Setting the initial scale guard for blank maps immediately, preventing
  auto-zoom when first geometry is added

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@adamrdrew adamrdrew merged commit 89e5c6a into master Jan 27, 2026
4 of 6 checks passed
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