mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
fix: mouse accidentally sticks and drag the node (#7186)
https://github.com/user-attachments/assets/88b76852-0050-4f16-a371-916af5232517 --------- Co-authored-by: Johnpaul Chiwetelu <49923152+Myestery@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user