mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 17:10:07 +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:
@@ -1,4 +1,5 @@
|
||||
import type { Positionable } from "../interfaces"
|
||||
import type { ConnectingLink, Positionable } from "../interfaces"
|
||||
import type { LinkId } from "@/LLink"
|
||||
|
||||
import { LGraphNode } from "@/LGraphNode"
|
||||
|
||||
@@ -35,3 +36,13 @@ export function findFirstNode(items: Iterable<Positionable>): LGraphNode | undef
|
||||
if (item instanceof LGraphNode) return item
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns `true` if the provided link ID is currently being dragged. */
|
||||
export function isDraggingLink(linkId: LinkId, connectingLinks: ConnectingLink[] | null | undefined): ConnectingLink | undefined {
|
||||
if (connectingLinks == null) return
|
||||
|
||||
for (const connectingLink of connectingLinks) {
|
||||
if (connectingLink.link == null) continue
|
||||
if (linkId === connectingLink.link.id) return connectingLink
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user