Fix new link follows pointer until context menu closed (#968)

- Resolves https://github.com/Comfy-Org/ComfyUI_frontend/issues/3618
This commit is contained in:
filtered
2025-04-26 02:33:28 +10:00
committed by GitHub
parent c10ce1caa1
commit 38dd58ae23
2 changed files with 8 additions and 3 deletions

View File

@@ -3951,7 +3951,7 @@ export class LGraphCanvas implements ConnectionColorContext {
/** Get the target snap / highlight point in graph space */
#getHighlightPosition(): ReadOnlyPoint {
return LiteGraph.snaps_for_comfy
? this._highlight_pos ?? this.graph_mouse
? this.linkConnector.state.snapLinksPos ?? this._highlight_pos ?? this.graph_mouse
: this.graph_mouse
}
@@ -3964,7 +3964,8 @@ export class LGraphCanvas implements ConnectionColorContext {
ctx: CanvasRenderingContext2D,
highlightPos: ReadOnlyPoint,
): void {
if (!this._highlight_pos) return
const linkConnectorSnap = !!this.linkConnector.state.snapLinksPos
if (!this._highlight_pos && !linkConnectorSnap) return
ctx.fillStyle = "#ffcc00"
ctx.beginPath()
@@ -3982,7 +3983,7 @@ export class LGraphCanvas implements ConnectionColorContext {
const { linkConnector } = this
const { overReroute, overWidget } = linkConnector
if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting) return
if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting || linkConnectorSnap) return
// Reroute highlight
if (overReroute) {

View File

@@ -32,6 +32,8 @@ export interface LinkConnectorState {
multi: boolean
/** When `true`, existing links are being repositioned. Otherwise, new links are being created. */
draggingExistingLinks: boolean
/** When set, connecting links will all snap to this position. */
snapLinksPos?: [number, number]
}
/** Discriminated union to simplify type narrowing. */
@@ -61,6 +63,7 @@ export class LinkConnector {
connectingTo: undefined,
multi: false,
draggingExistingLinks: false,
snapLinksPos: undefined,
}
readonly events = new LinkConnectorEventTarget()
@@ -639,6 +642,7 @@ export class LinkConnector {
hiddenReroutes.clear()
state.multi = false
state.draggingExistingLinks = false
state.snapLinksPos = undefined
}
}