mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-28 18:22:40 +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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let hasDraggingStarted = false
|
||||||
|
|
||||||
const startPosition = ref({ x: 0, y: 0 })
|
const startPosition = ref({ x: 0, y: 0 })
|
||||||
|
|
||||||
const DRAG_THRESHOLD = 3 // pixels
|
const DRAG_THRESHOLD = 3 // pixels
|
||||||
@@ -57,7 +59,7 @@ export function useNodePointerInteractions(
|
|||||||
|
|
||||||
startPosition.value = { x: event.clientX, y: event.clientY }
|
startPosition.value = { x: event.clientX, y: event.clientY }
|
||||||
|
|
||||||
startDrag(event, nodeId)
|
safeDragStart(event, nodeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onPointermove(event: PointerEvent) {
|
function onPointermove(event: PointerEvent) {
|
||||||
@@ -78,7 +80,7 @@ export function useNodePointerInteractions(
|
|||||||
if (lmbDown && multiSelect && !layoutStore.isDraggingVueNodes.value) {
|
if (lmbDown && multiSelect && !layoutStore.isDraggingVueNodes.value) {
|
||||||
layoutStore.isDraggingVueNodes.value = true
|
layoutStore.isDraggingVueNodes.value = true
|
||||||
handleNodeSelect(event, nodeId)
|
handleNodeSelect(event, nodeId)
|
||||||
startDrag(event, nodeId)
|
safeDragStart(event, nodeId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Check if we should start dragging (pointer moved beyond threshold)
|
// Check if we should start dragging (pointer moved beyond threshold)
|
||||||
@@ -102,6 +104,14 @@ export function useNodePointerInteractions(
|
|||||||
layoutStore.isDraggingVueNodes.value = false
|
layoutStore.isDraggingVueNodes.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function safeDragStart(event: PointerEvent, nodeId: string) {
|
||||||
|
try {
|
||||||
|
startDrag(event, nodeId)
|
||||||
|
} finally {
|
||||||
|
hasDraggingStarted = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function safeDragEnd(event: PointerEvent) {
|
function safeDragEnd(event: PointerEvent) {
|
||||||
try {
|
try {
|
||||||
const nodeId = toValue(nodeIdRef)
|
const nodeId = toValue(nodeIdRef)
|
||||||
@@ -109,6 +119,7 @@ export function useNodePointerInteractions(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error during endDrag:', error)
|
console.error('Error during endDrag:', error)
|
||||||
} finally {
|
} finally {
|
||||||
|
hasDraggingStarted = false
|
||||||
cleanupDragState()
|
cleanupDragState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,9 +134,12 @@ export function useNodePointerInteractions(
|
|||||||
}
|
}
|
||||||
const wasDragging = layoutStore.isDraggingVueNodes.value
|
const wasDragging = layoutStore.isDraggingVueNodes.value
|
||||||
|
|
||||||
if (wasDragging) {
|
if (hasDraggingStarted || wasDragging) {
|
||||||
safeDragEnd(event)
|
safeDragEnd(event)
|
||||||
return
|
|
||||||
|
if (wasDragging) {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip selection handling for right-click (button 2) - context menu handles its own selection
|
// Skip selection handling for right-click (button 2) - context menu handles its own selection
|
||||||
|
|||||||
Reference in New Issue
Block a user