Editor has no 'snap to path' or 'snap to other path's nodes' — user trying to align a new path to an existing path's node has to estimate, no automatic snap-to-other-path #303

Closed
opened 2026-10-04 03:48:48 +00:00 by Mark · 1 comment
Owner

Finding

grep -rn 'snapToOtherPath\|snapToPath' src/components/editor/ returns 0. The editor has snap to grid, snap to nodes (within the same path), but no snap to other paths' nodes.

A user drawing a new path:

  • Wants the start node to align with an existing path's mid-node
  • Has to drag carefully to match
  • No visual indicator when the new node is near an existing one

The fix is snap-to-other-path-nodes.

Where

  • SnapSettings: src/components/editor/types.ts (existing fields: snapToNodes, snapToGrid, snapToHoop)
  • No snap to other paths: grep -rn 'snapToOtherPath' src/components/editor/ returns 0
  • Geometry module: src/components/editor/geometry.ts (where the algorithm lives)

Suggested fix shape

  1. Algorithm: in the geometry module, when computing snap candidates, include all nodes from all paths:
function getSnapCandidates(currentPath: StitchPath, allPaths: StitchPath[]) {
  const candidates: SnapPoint[] = [];
  for (const path of allPaths) {
    if (path.id === currentPath.id) continue;
    for (const node of path.nodes) {
      candidates.push({ x: node.x, y: node.y, type: 'other-path-node', pathId: path.id });
    }
  }
  return candidates;
}
  1. UI: when the new path's node is within 2mm of an existing path's node, snap to it and show a visual indicator (a small circle around the snap target).

  2. Toggle: a "Snap to other paths" toggle in the snap settings (default: on).

  3. Modifier: hold Alt to disable snap (like most editors' "no snap" modifier).

Severity

Low. The user can use the grid. Power users with precise alignment needs notice.

Discovered by

Gap analysis (2026-10-02) of editor snap affordances.

  • The snap settings are in SnapSettings. Adding snapToOtherPaths: boolean is the type change.
  • #288 (open) — Grid overlay. Same surface; the grid is the visual.
  • Figma/Illustrator have smart guides that snap to other objects' edges, midpoints, etc. The editor's snap-to-other-paths is the simpler version.
## Finding `grep -rn 'snapToOtherPath\|snapToPath' src/components/editor/` returns 0. The editor has snap to grid, snap to nodes (within the same path), but no snap to other paths' nodes. A user drawing a new path: - Wants the start node to align with an existing path's mid-node - Has to drag carefully to match - No visual indicator when the new node is near an existing one The fix is snap-to-other-path-nodes. ## Where - SnapSettings: `src/components/editor/types.ts` (existing fields: snapToNodes, snapToGrid, snapToHoop) - No snap to other paths: `grep -rn 'snapToOtherPath' src/components/editor/` returns 0 - Geometry module: `src/components/editor/geometry.ts` (where the algorithm lives) ## Suggested fix shape 1. **Algorithm**: in the geometry module, when computing snap candidates, include all nodes from all paths: ```ts function getSnapCandidates(currentPath: StitchPath, allPaths: StitchPath[]) { const candidates: SnapPoint[] = []; for (const path of allPaths) { if (path.id === currentPath.id) continue; for (const node of path.nodes) { candidates.push({ x: node.x, y: node.y, type: 'other-path-node', pathId: path.id }); } } return candidates; } ``` 2. **UI**: when the new path's node is within 2mm of an existing path's node, snap to it and show a visual indicator (a small circle around the snap target). 3. **Toggle**: a "Snap to other paths" toggle in the snap settings (default: on). 4. **Modifier**: hold Alt to disable snap (like most editors' "no snap" modifier). ## Severity Low. The user can use the grid. Power users with precise alignment needs notice. ## Discovered by Gap analysis (2026-10-02) of editor snap affordances. ## Related - The snap settings are in `SnapSettings`. Adding `snapToOtherPaths: boolean` is the type change. - #288 (open) — Grid overlay. Same surface; the grid is the visual. - Figma/Illustrator have smart guides that snap to other objects' edges, midpoints, etc. The editor's snap-to-other-paths is the simpler version.
Author
Owner

Shipped at dafcd8b on origin/main. SnapSettings gains snapToOtherPaths: boolean (default true) with a right-panel toggle; applySnap now takes an otherPathNodes: PathNode[] parameter that joins the snap-to-nodes search only when the toggle is on, AFTER own-path candidates so a sibling still wins at equal distance; SnapResult carries a target discriminator so the canvas paints a dashed ring when the snap grabbed a node on a different path than the one being edited. 9/9 new tests pass (issue-303.test.tsx), 666/666 editor tests pass.

Shipped at dafcd8b on origin/main. `SnapSettings` gains `snapToOtherPaths: boolean` (default true) with a right-panel toggle; `applySnap` now takes an `otherPathNodes: PathNode[]` parameter that joins the snap-to-nodes search only when the toggle is on, AFTER own-path candidates so a sibling still wins at equal distance; `SnapResult` carries a `target` discriminator so the canvas paints a dashed ring when the snap grabbed a node on a different path than the one being edited. 9/9 new tests pass (issue-303.test.tsx), 666/666 editor tests pass.
Mark closed this issue 2026-10-04 21:30:01 +00:00
Sign in to join this conversation.
No description provided.