fix mmb navigation when click starts on Vue nodes (#5921)

## Summary

Fixes https://github.com/Comfy-Org/ComfyUI_frontend/issues/5860
by updating Vue node pointer interactions to forward middle mouse button
events to canvas instead of handling them locally.

## Review Focus

Middle mouse button event detection logic using both `button` property
and `buttons` bitmask for cross-browser compatibility. Test coverage for
pointer event forwarding behavior.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-5921-fix-mmb-navigation-when-click-starts-on-Vue-nodes-2826d73d3650819688eec4600666755d)
by [Unito](https://www.unito.io)

---------

Co-authored-by: DrJKL <DrJKL@users.noreply.github.com>
This commit is contained in:
Christian Byrne
2025-10-06 10:23:39 -07:00
committed by GitHub
parent dc0b729efa
commit 2cb078cd9e
5 changed files with 76 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
import { type MaybeRefOrGetter, computed, onUnmounted, ref, toValue } from 'vue'
import { isMiddlePointerInput } from '@/base/pointerUtils'
import type { VueNodeData } from '@/composables/graph/useGraphNodeManager'
import { useCanvasInteractions } from '@/renderer/core/canvas/useCanvasInteractions'
import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
@@ -34,6 +35,12 @@ export function useNodePointerInteractions(
const { forwardEventToCanvas, shouldHandleNodePointerEvents } =
useCanvasInteractions()
const forwardMiddlePointerIfNeeded = (event: PointerEvent) => {
if (!isMiddlePointerInput(event)) return false
forwardEventToCanvas(event)
return true
}
// Drag state for styling
const isDragging = ref(false)
const dragStyle = computed(() => {
@@ -52,6 +59,8 @@ export function useNodePointerInteractions(
return
}
if (forwardMiddlePointerIfNeeded(event)) return
const stopNodeDragTarget =
event.target instanceof HTMLElement
? event.target.closest('[data-capture-node="true"]')
@@ -90,6 +99,8 @@ export function useNodePointerInteractions(
}
const handlePointerMove = (event: PointerEvent) => {
if (forwardMiddlePointerIfNeeded(event)) return
if (isDragging.value) {
void handleDrag(event)
}
@@ -129,6 +140,8 @@ export function useNodePointerInteractions(
}
const handlePointerUp = (event: PointerEvent) => {
if (forwardMiddlePointerIfNeeded(event)) return
if (isDragging.value) {
handleDragTermination(event, 'drag end')
}