[backport core/1.34] fix: mouse accidentally sticks and drag the node (#7500)

Backport of #7186 to `core/1.34`

Automatically created by backport workflow.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7500-backport-core-1-34-fix-mouse-accidentally-sticks-and-drag-the-node-2ca6d73d3650814694b4cfc6700027c2)
by [Unito](https://www.unito.io)

Co-authored-by: Rizumu Ayaka <rizumu@ayaka.moe>
Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com>
This commit is contained in:
Comfy Org PR Bot
2025-12-16 04:30:22 +09:00
committed by GitHub
parent a7d365062b
commit dfcb83479e

View File

@@ -26,6 +26,8 @@ export function useNodePointerInteractions(
return true
}
let hasDraggingStarted = false
const startPosition = ref({ x: 0, y: 0 })
const DRAG_THRESHOLD = 3 // pixels
@@ -57,7 +59,7 @@ export function useNodePointerInteractions(
startPosition.value = { x: event.clientX, y: event.clientY }
startDrag(event, nodeId)
safeDragStart(event, nodeId)
}
function onPointermove(event: PointerEvent) {
@@ -78,7 +80,7 @@ export function useNodePointerInteractions(
if (lmbDown && multiSelect && !layoutStore.isDraggingVueNodes.value) {
layoutStore.isDraggingVueNodes.value = true
handleNodeSelect(event, nodeId)
startDrag(event, nodeId)
safeDragStart(event, nodeId)
return
}
// Check if we should start dragging (pointer moved beyond threshold)
@@ -102,6 +104,14 @@ export function useNodePointerInteractions(
layoutStore.isDraggingVueNodes.value = false
}
function safeDragStart(event: PointerEvent, nodeId: string) {
try {
startDrag(event, nodeId)
} finally {
hasDraggingStarted = true
}
}
function safeDragEnd(event: PointerEvent) {
try {
const nodeId = toValue(nodeIdRef)
@@ -109,6 +119,7 @@ export function useNodePointerInteractions(
} catch (error) {
console.error('Error during endDrag:', error)
} finally {
hasDraggingStarted = false
cleanupDragState()
}
}
@@ -123,9 +134,12 @@ export function useNodePointerInteractions(
}
const wasDragging = layoutStore.isDraggingVueNodes.value
if (wasDragging) {
if (hasDraggingStarted || wasDragging) {
safeDragEnd(event)
return
if (wasDragging) {
return
}
}
// Skip selection handling for right-click (button 2) - context menu handles its own selection