diff --git a/src/components/WorkflowCanvas.tsx b/src/components/WorkflowCanvas.tsx index 52ec031c..bd25e2db 100644 --- a/src/components/WorkflowCanvas.tsx +++ b/src/components/WorkflowCanvas.tsx @@ -268,6 +268,8 @@ const findScrollableAncestor = (target: HTMLElement, deltaX: number, deltaY: num /** Shared ref so child components (BaseNode) can check panning state without re-rendering */ export const isPanningRef = { current: false }; +/** Shared ref so child components (BaseNode) can skip hover updates during node drags */ +export const isDraggingNodeRef = { current: false }; export function WorkflowCanvas() { const { nodes, edges, groups, isModalOpen, showQuickstart, navigationTarget, canvasNavigationSettings, dimmedNodeIds } = @@ -1964,7 +1966,8 @@ export function WorkflowCanvas() { onConnectEnd={handleConnectEnd} onMoveStart={() => { isPanningRef.current = true; setHoveredNodeId(null); }} onMoveEnd={() => { isPanningRef.current = false; }} - onNodeDragStop={handleNodeDragStop} + onNodeDragStart={() => { isDraggingNodeRef.current = true; }} + onNodeDragStop={(event, node) => { isDraggingNodeRef.current = false; handleNodeDragStop(event, node); }} onSelectionChange={handleSelectionChange} nodeTypes={nodeTypes} edgeTypes={edgeTypes} diff --git a/src/components/nodes/BaseNode.tsx b/src/components/nodes/BaseNode.tsx index d5373219..40288b53 100644 --- a/src/components/nodes/BaseNode.tsx +++ b/src/components/nodes/BaseNode.tsx @@ -3,7 +3,7 @@ import { ReactNode, useCallback, useRef, useLayoutEffect } from "react"; import { Node, NodeResizer, OnResize, useReactFlow } from "@xyflow/react"; import { useWorkflowStore } from "@/store/workflowStore"; -import { isPanningRef } from "@/components/WorkflowCanvas"; +import { isPanningRef, isDraggingNodeRef } from "@/components/WorkflowCanvas"; import { getMediaDimensions, calculateAspectFitSize } from "@/utils/nodeDimensions"; const DEFAULT_NODE_DIMENSION = 300; @@ -297,15 +297,15 @@ export function BaseNode({ ${className} `} onMouseEnter={() => { - if (isPanningRef.current) return; + if (isPanningRef.current || isDraggingNodeRef.current) return; setHoveredNodeId(id); }} onMouseLeave={() => { - if (isPanningRef.current) return; + if (isPanningRef.current || isDraggingNodeRef.current) return; setHoveredNodeId(null); }} > -