Skip to content

feat(canvas): add a Hand tool for panning the canvas - #838

Open
mstonedev wants to merge 2 commits into
CoreBunch:mainfrom
mstonedev:feat/canvas-hand-tool
Open

mstonedev wants to merge 2 commits into
CoreBunch:mainfrom
mstonedev:feat/canvas-hand-tool

Conversation

@mstonedev

@mstonedev mstonedev commented Nov 26, 2026 •

Copy link
Copy Markdown

What changed

Adds a Hand tool to the design canvas. While it's on, a plain left-drag pans the canvas instead of selecting.

  • Ways to turn it on: a hand button in the canvas mode pill (design view only), the H shortcut, and a "Toggle Hand tool" Spotlight command.
  • Behaviour while on: any left-drag pans, on the empty canvas and over frames. This includes a pen that the browser reports as a mouse. Taps never select: the frame relay swallows click, dblclick and dragstart. The canvas root and every frame show a grab cursor.
  • Refactor:
    • The keyboard and pointer relay moves out of IframeFrameSurface into a new useIframeInputRelay hook.
    • The pan policy in canvasPanInput.ts now takes primaryButtonPans, which is true when Space is held or the Hand tool is on.
    • canvasMode narrows to 'select' | 'pan', and setCanvasMode is replaced by toggleHandTool.
  • Delete shortcut: Delete/Backspace pressed while a frame has focus is now handled by a document-level listener, useCanvasDocumentDeleteShortcut. Before this, the keystroke was forwarded to the parent document but never reached the canvas's delete handling.

Why

Tablet and pen users couldn't pan the canvas. Panning needed Space + drag or a middle-button drag, and a pen has neither a free hand for Space nor a middle button.

Impact

  • Users: a new tool and the H shortcut. Select-mode behaviour is unchanged.
  • Developers: frame input relaying now lives in useIframeInputRelay.ts. Docs updated in docs/editor.md, docs/features/canvas-iframe-per-frame.md and docs/features/spotlight.md. The E2E feature matrix has a new SITE-029 entry.

Verification

Run locally on macOS with Bun 1.4.2, at commit ea5cc1be:

  • bun run build: passes, exit 0 (tsc -b and the Vite build).
  • bun test: 8,981 passed, 0 failed, 57 skipped, across 918 files.
  • bun run lint: clean, exit 0.
  • bunx playwright test --project=e2e tests/e2e/canvas-hand-tool.e2e.ts: SITE-029 passes ("a left-drag over a page frame pans the canvas without selecting"). Playwright reports 6 passed because the run also includes the five setup and fixture tests every spec depends on.

Not run yet:

  • A manual check with a pen tablet and a mouse: Hand tool pans, taps don't select, and select-mode clicks, Space+drag and middle-drag behave as before.

mstonedev and others added 2 commits November 26, 2026 11:59
Add a Hand tool to the design canvas so tablet and pen users can pan with
a plain drag, without holding Space or using a middle button.

- Hand tool toggle in the canvas mode pill (design view only), the `H`
  shortcut, and a "Toggle Hand tool" Spotlight command.
- While active, any left-drag pans, over the empty canvas and over
  frames; taps never select. Frames and the canvas root show a grab
  cursor.
- Extract the frame keyboard/pointer relay from IframeFrameSurface into
  useIframeInputRelay; pan policy now takes `primaryButtonPans`.
- canvasMode narrows to 'select' | 'pan' with a toggleHandTool action.
- Delete/Backspace forwarded from a focused frame is handled by a
  document-level listener (useCanvasDocumentDeleteShortcut).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keyboard forwarding and the cross-frame pointer relay moved from
IframeFrameSurface into useIframeInputRelay. Update the comments and the
canvas-iframe-per-frame doc line that still credited IframeFrameSurface,
and widen the panPointerId comment to cover middle-drag and Hand tool pans.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mstonedev
mstonedev force-pushed the feat/canvas-hand-tool branch from 891e66c to ea5cc1b Compare November 26, 2026 17:09
@mstonedev
mstonedev marked this pull request as ready for review November 26, 2026 17:40

This branch has not been deployed

No deployments
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