Repository navigation
feat(canvas): quick ways past the canvas lock (#1130) - #1167
Open
probertson wants to merge 1 commit into
Open
probertson wants to merge 1 commit into
probertson wants to merge 1 commit into
Conversation
…close the middle-drag leak Issue eneskirca#1130. Three pieces: - ⌘+middle-drag (Ctrl off-mac) pans the camera anywhere, locked or not — the explicit "move the map" gesture. Its own capture-phase pointer handler (React Flow's panOnDrag selects buttons only); cancelling the pointerdown keeps d3, d3-drag and xterm from seeing it. - "Toggle canvas lock" (canvas.toggleLock) in the keybinding registry, shipped unbound; like every canvas command it does not fire while a terminal has the keyboard. - The lock now really freezes a plain middle-drag: React Flow accepts a middle press on a node, edge or selection before reading panOnDrag, so a drag started on a node header or a terminal's hover guard panned past the lock. While locked, a bubble-phase listener on the viewport stops that press after the node has seen it. The lock tooltip and the ⌘/ shortcuts panel mention the gesture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1130.
The canvas lock is most useful left on, but moving the camera meant unlocking, panning and locking again. This adds two quick ways past it, and fixes a leak that made the lock not quite a lock.
1. ⌘+middle-drag pans the canvas, locked or not (Ctrl+middle-drag on Windows/Linux). It works anywhere on the canvas, including over a terminal; holding the modifier is what says "I meant to move the map". Plain middle-drag is unchanged in meaning: it pans when unlocked and does nothing when locked. React Flow's
panOnDragselects mouse buttons only, so this is the canvas's own pointer handler (lib/modifierPan.ts, same shape as the wheel-zoom handler). It cancels thepointerdownin the capture phase, so nomousedownreaches React Flow's drag/zoom or xterm, and swallows the trailingauxclick(Linux middle-click paste).2. "Toggle canvas lock" shortcut (
canvas.toggleLock, Canvas group in Settings → Keyboard Shortcuts). Like every canvas command, it doesn't fire while a terminal has the keyboard.3. Fix: plain middle-drag leaked past the lock over nodes. React Flow's zoom filter (
@xyflow/systemcreateFilter) accepts a middle-buttonmousedownon a node, edge or selection before it readspanOnDrag, so turningpanOnDragoff never stopped a middle-drag that started on a node. In practice:The commit that defined the lock (
c6be32c5) records "locked, middle-drag does not pan" as verified, so this reads as an unnoticed library default rather than intended behavior. While locked, a bubble-phase listener on.react-flow__viewportstops a middlemousedownafter the node has seen it, so tmux and the middle-click paste setting behave as before; only React Flow's listener on an ancestor is cut off.Discoverability: the locked button's tooltip says "⌘+middle-drag still pans", and the ⌘/ shortcuts panel lists the gesture.
Question for review: should "Toggle canvas lock" have a default key? I shipped it unbound. My suggestion would be ⌘⇧K / Ctrl+Shift+K: nothing in the registry or the app menu uses it. ⌘⇧L reads better for "lock" but is the sessions sidebar's. Trackpad-only Mac users have no middle button, so for them the shortcut is the whole feature, which argues for a default.
How it was checked
modifierPan.test.ts: the gesture predicate (⌘ on mac, Ctrl elsewhere, no extra modifiers), pan deltas, capture-phase cancel,auxclickswallowed, plain middle-drag left alone, and the locked guard (node still sees the press, React Flow doesn't; left/right untouched; removed on unlock). Registry test updated.npm run typecheckclean;src/renderer/lib,src/renderer/canvas, shortcuts panel and keybinding suites pass (3,922 tests).Not checked: Windows/Linux Ctrl+middle-drag, and the Server Edition in a real browser. One behavior change to note: on Windows/Linux, a Ctrl+middle press over a terminal now pans instead of being passed to the terminal app.
🤖 Generated with Claude Code