From 8e6d0a7f2fccea61b192912f2040d7872e22ecc2 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sat, 28 Feb 2026 01:21:45 +0300 Subject: [PATCH] Fix snap guides using sibling nodes in absolute coordinates Snap targets are now siblings of the moving node (not root children), converted to absolute coordinates. This fixes guides not reflecting resized objects. --- src/composables/use-canvas-input.ts | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/composables/use-canvas-input.ts b/src/composables/use-canvas-input.ts index f781fd950..0f246140b 100644 --- a/src/composables/use-canvas-input.ts +++ b/src/composables/use-canvas-input.ts @@ -534,8 +534,27 @@ export function useCanvasInput(canvasRef: Ref, store: const bounds = computeSelectionBounds(selectedNodes) if (bounds) { - const allNodes = store.graph.getChildren(store.graph.rootId) - const snap = computeSnap(store.state.selectedIds, bounds, allNodes) + // Snap against siblings in absolute coordinates + const firstId = [...d.originals.keys()][0] + const firstNode = store.graph.getNode(firstId) + const parentId = firstNode?.parentId ?? store.graph.rootId + const siblings = store.graph.getChildren(parentId) + const parentAbs = parentId !== store.graph.rootId + ? store.graph.getAbsolutePosition(parentId) + : { x: 0, y: 0 } + const absTargets = siblings.map((n) => ({ + ...n, + x: n.x + parentAbs.x, + y: n.y + parentAbs.y + })) + // Convert moving bounds to absolute coords too + const absBounds = { + x: bounds.x + parentAbs.x, + y: bounds.y + parentAbs.y, + width: bounds.width, + height: bounds.height + } + const snap = computeSnap(store.state.selectedIds, absBounds, absTargets) dx += snap.dx dy += snap.dy store.setSnapGuides(snap.guides)