mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 08:30:06 +00:00
Improve connecting link logic (#697)
### Current - Connections are disconnected the moment a link starts being dragged - Reseating a connection where it came from creates a new connection - If the process is somehow interrupted, the links are already gone ### Proposed - Connection is disconnected after a new connection is made - Rendering is bypassed for the link segment being moved - Does nothing if dropping a link exactly where it came from - Adds early return when trying to connect a node to itself
This commit is contained in:
@@ -2170,7 +2170,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
node: LGraphNode,
|
||||
slotType: ISlotType,
|
||||
options?: ConnectByTypeOptions,
|
||||
): number | null {
|
||||
): number | undefined {
|
||||
// LEGACY: Old options names
|
||||
if (options && typeof options === "object") {
|
||||
if ("firstFreeIfInputGeneralInCase" in options) options.wildcardToTyped = !!options.firstFreeIfInputGeneralInCase
|
||||
@@ -2188,7 +2188,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
|
||||
if (node && typeof node === "number") {
|
||||
const nodeById = this.graph.getNodeById(node)
|
||||
if (!nodeById) return null
|
||||
if (!nodeById) return
|
||||
|
||||
node = nodeById
|
||||
}
|
||||
@@ -2217,7 +2217,6 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
: node.findOutputSlotFree(opt)
|
||||
if (nonEventSlot >= 0) return nonEventSlot
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2239,7 +2238,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
target_slotType,
|
||||
optsIn,
|
||||
)
|
||||
if (slotIndex !== null)
|
||||
if (slotIndex !== undefined)
|
||||
return this.connect(slot, target_node, slotIndex, optsIn?.afterRerouteId)
|
||||
|
||||
console.debug("[connectByType]: no way to connect type:", target_slotType, "to node:", target_node)
|
||||
@@ -2270,7 +2269,7 @@ export class LGraphNode implements Positionable, IPinnable, IColorable {
|
||||
source_slotType,
|
||||
optsIn,
|
||||
)
|
||||
if (slotIndex !== null)
|
||||
if (slotIndex !== undefined)
|
||||
return source_node.connect(slotIndex, this, slot, optsIn?.afterRerouteId)
|
||||
|
||||
console.debug("[connectByType]: no way to connect type:", source_slotType, "to node:", source_node)
|
||||
|
||||
Reference in New Issue
Block a user