Skip to content

Add hover focus ring with modifier-based parent targeting#2

Open
alizme wants to merge 2 commits intomasterfrom
hover-focus-ring-on-frames
Open

Add hover focus ring with modifier-based parent targeting#2
alizme wants to merge 2 commits intomasterfrom
hover-focus-ring-on-frames

Conversation

@alizme
Copy link
Copy Markdown

@alizme alizme commented Mar 30, 2026

Summary

  • Adds a hover focus ring (2px blue outline) that appears when hovering frames and text nodes on the canvas
  • Holding Cmd (Mac) / Ctrl (Windows) promotes the hover target to the nearest parent frame, and clicking while held selects that parent
  • Uses a single pointermove handler with DOM walking for robust hit-testing across nested and overlapping frames

Details

New file: hover-ring.svelte
Lightweight overlay component — positioned via getBoundingClientRect math, pointer-events-none, rendered below selection overlay (z-5 vs z-10).

EditorState changes:

  • #deepHoveredNodeId tracks the deepest hovered node from pointer movement
  • #modifierHeld tracks Cmd/Ctrl key state
  • #displayedHoveredNodeId (derived) promotes to parent frame when modifier is held, falls back to deep target if no eligible parent exists
  • isHoverableNode(id) — checks node is a frame or text and visible
  • Hover measurements update reactively on pan/zoom changes

Canvas changes:

  • pointermove walks DOM from e.target upward to find nearest [data-id] element passing isHoverableNode
  • Cmd/Ctrl keydown/keyup tracked globally (before input guards) with onblur fallback
  • Click with modifier held selects the promoted hover target instead of the deepest node
  • Ring hidden during pan mode (spaceHeld) and when hovering the selected node

Test plan

  • Hover a frame → ring appears
  • Leave frame → ring disappears
  • Hover text node → ring appears on text node
  • Only one ring visible at a time
  • Ring does not affect layout or intercept clicks
  • Pan/zoom → ring follows correctly
  • Hover selected frame → no duplicate ring
  • Nested frames → deepest frame gets ring
  • Hold Cmd/Ctrl → ring promotes to parent frame
  • Release Cmd/Ctrl → ring reverts to deep target
  • Cmd/Ctrl + click → selects parent frame
  • Cmd-tab away → modifier state clears (no stuck state)

🤖 Generated with Claude Code

alizme and others added 2 commits March 30, 2026 14:42
…rames

Adds a visible outline ring when hovering frames and text nodes on the
canvas, with Cmd/Ctrl modifier support to promote the hover target to
the nearest parent frame. Clicking while the modifier is held selects
the promoted parent.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When Cmd/Ctrl is held and a frame is selected, the hover ring now
promotes from the selected frame to its parent rather than from the
deepest hovered frame. This allows reliable upward targeting in deeply
nested structures where children share identical bounds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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