mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-24 00:34:09 +00:00
fix Vue nodes capturing wheel event when Ctrl+Shift+drag zooming (#5791)
## Summary Fixed canvas read-only state during Ctrl+Shift drag-to-zoom to prevent node interaction conflicts. This fix also benefits Litegraph nodes. ## Changes - **What**: Canvas becomes read-only during [Ctrl+Shift drag zoom](https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent) operations and restores original state when finished - **What**: Added browser test coverage for zoom interaction behavior ## Review Focus State restoration on zoom interruption and edge cases where drag zoom is cancelled mid-operation. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5791-fix-Vue-nodes-capturing-wheel-event-when-Ctrl-Shift-drag-zooming-27a6d73d3650817d888ee59f8f7fcb01) by [Unito](https://www.unito.io) --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -688,8 +688,8 @@ export class LGraphCanvas
|
||||
|
||||
/** If true, enable drag zoom. Ctrl+Shift+Drag Up/Down: zoom canvas. */
|
||||
dragZoomEnabled: boolean = false
|
||||
/** The start position of the drag zoom. */
|
||||
#dragZoomStart: { pos: Point; scale: number } | null = null
|
||||
/** The start position of the drag zoom and original read-only state. */
|
||||
#dragZoomStart: { pos: Point; scale: number; readOnly: boolean } | null = null
|
||||
|
||||
getMenuOptions?(): IContextMenuValue<string>[]
|
||||
getExtraMenuOptions?(
|
||||
@@ -2188,7 +2188,12 @@ export class LGraphCanvas
|
||||
!e.altKey &&
|
||||
e.buttons
|
||||
) {
|
||||
this.#dragZoomStart = { pos: [e.x, e.y], scale: this.ds.scale }
|
||||
this.#dragZoomStart = {
|
||||
pos: [e.x, e.y],
|
||||
scale: this.ds.scale,
|
||||
readOnly: this.read_only
|
||||
}
|
||||
this.read_only = true
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3125,7 +3130,7 @@ export class LGraphCanvas
|
||||
#processDragZoom(e: PointerEvent): void {
|
||||
// stop canvas zoom action
|
||||
if (!e.buttons) {
|
||||
this.#dragZoomStart = null
|
||||
this.#finishDragZoom()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3143,6 +3148,13 @@ export class LGraphCanvas
|
||||
this.graph.change()
|
||||
}
|
||||
|
||||
#finishDragZoom(): void {
|
||||
const start = this.#dragZoomStart
|
||||
if (!start) return
|
||||
this.#dragZoomStart = null
|
||||
this.read_only = start.readOnly
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a mouse move event has to be processed
|
||||
*/
|
||||
@@ -3524,6 +3536,8 @@ export class LGraphCanvas
|
||||
const { graph, pointer } = this
|
||||
if (!graph) return
|
||||
|
||||
this.#finishDragZoom()
|
||||
|
||||
LGraphCanvas.active_canvas = this
|
||||
|
||||
this.adjustMouseEvent(e)
|
||||
|
||||
Reference in New Issue
Block a user