Keep pinch zoom optical instead of reflowing the workspace #392
- MA
## Why
On a Mac trackpad (or a phone), pinch-to-zoom in Chopin enlarged the whole page layout instead of magnifying a region like other sites. `useVisualViewport` sizes `#root` from `window.visualViewport` so the workspace stays above the on-screen keyboard. A pinch zoom also shrinks and moves the visual viewport, so the app re-laid itself out inside the zoomed region: at 2x on a 1440×900 window, `#root` became 720×450, the layout switched to the compact tabbed workspace, and the browser then magnified that.
## What changed
- `viewportVars` follows the visual viewport only when `visualViewport.scale` is ~1 (keyboard and browser-chrome cases). While pinch zoomed it keeps the layout viewport (`left/top 0`, width 100%, height `innerHeight`), so the browser zooms optically. - Unit tests for the zoomed and keyboard-shifted cases. - E2E: a 2x pinch zoom (CDP `Emulation.setPageScaleFactor`) on a 1440×900 desktop keeps `#root` at 1440×900 and the split layout. The existing visual-viewport keyboard tests all emulate scale 1 and are unchanged.
## Screenshots
Desktop 1440×900 after a 2× pinch at (720, 300). Before, the workspace reflowed into the zoomed region; after, the desktop layout is magnified around the pinch point.
  
Measured in headless Chromium with the same gesture: before `#root` = 360,150 720×450; after `#root` = 0,0 1440×900 while `visualViewport` = 360,150 720×450 scale 2.
## Verification
- Four commits, including the `currentViewport()` simplification, remain patch-identical on the refreshed stack. - Focused viewport tests: 5 passed. `bun run fix`, `bun run ci`, `bun run types`, and `bun run build` passed; the reviewed viewport design hash is renewed. - Initial JavaScript is 251,596 B raw / 79,415 B gzip, 4,404 bytes below the raw limit. Fresh GitHub CI must run after the prepared head is published.
MaggieAppletonauto-rebase-enabledlast month on GitHub
MaggieAppletonauto-merge-disabledlast month on GitHub
MaggieAppletonhead-ref-force-pushed 0d3b3ddd2737last month on GitHub
MaggieAppletonmerged cd40d0f538cdlast month on GitHub
MaggieAppletonhead-ref-deletedlast month on GitHub