From e96593fe4c5d13f49a4c4b27438c1e641a96f4d7 Mon Sep 17 00:00:00 2001 From: Terry Jia Date: Sun, 14 Dec 2025 22:13:00 -0500 Subject: [PATCH] fix: prevent unrelated groups from moving when dragging nodes in vueNodes mode (#7473) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Previously, when dragging a node that was not part of the selection, any selected groups would still move along with it. This fix ensures groups only move when the dragged node is actually part of the selection. ## Screenshots (if applicable) before https://github.com/user-attachments/assets/ff9a18c2-59b2-4bbd-81b4-7a6ecb35e659 after https://github.com/user-attachments/assets/019a6cc6-b1e2-41d1-bfec-d6af7ae84091 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7473-fix-prevent-unrelated-groups-from-moving-when-dragging-nodes-in-vueNodes-mode-2c96d73d365081a194a6fef57f9c1108) by [Unito](https://www.unito.io) --- .../extensions/vueNodes/layout/useNodeDrag.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/renderer/extensions/vueNodes/layout/useNodeDrag.ts b/src/renderer/extensions/vueNodes/layout/useNodeDrag.ts index fb6e86635..9b0cb8c47 100644 --- a/src/renderer/extensions/vueNodes/layout/useNodeDrag.ts +++ b/src/renderer/extensions/vueNodes/layout/useNodeDrag.ts @@ -57,7 +57,10 @@ function useNodeDragIndividual() { const selectedNodes = toValue(selectedNodeIds) // capture the starting positions of all other selected nodes - if (selectedNodes?.has(nodeId) && selectedNodes.size > 1) { + // Only move other selected items if the dragged node is part of the selection + const isDraggedNodeInSelection = selectedNodes?.has(nodeId) + + if (isDraggedNodeInSelection && selectedNodes.size > 1) { otherSelectedNodesStartPositions = new Map() for (const id of selectedNodes) { @@ -73,9 +76,15 @@ function useNodeDragIndividual() { otherSelectedNodesStartPositions = null } - // Capture selected groups (filter from selectedItems which only contains selected items) - selectedGroups = toValue(selectedItems).filter(isLGraphGroup) - lastCanvasDelta = { x: 0, y: 0 } + // Capture selected groups only if the dragged node is part of the selection + // This prevents groups from moving when dragging an unrelated node + if (isDraggedNodeInSelection) { + selectedGroups = toValue(selectedItems).filter(isLGraphGroup) + lastCanvasDelta = { x: 0, y: 0 } + } else { + selectedGroups = null + lastCanvasDelta = null + } mutations.setSource(LayoutSource.Vue) }