mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-13 17:10:06 +00:00
Add functionality to quickly disconnect moved input links (#7459)
Disconnections are frequently performed by dragging a link from an input slot and dropping it on the canvas, but needing to wait for the searchbox to pop up, and then needing to manually close out of this can make it feel slow. Sometimes, this will even result in users disabling the link release action for more responsive graph building. Instead, this PR introduces new functionality where a link which is moved only a short distance from a node input and dropped will be immediately disconnected instead of performing the default link release action.  ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7459-Add-functionality-to-quickly-disconnect-moved-input-links-2c86d73d365081919052f3856db8e672) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type { SlotLayout } from '@/renderer/core/layout/types'
|
||||
import type { Point } from '@/lib/litegraph/src/interfaces'
|
||||
import type { LGraph } from '@/lib/litegraph/src/LGraph'
|
||||
import type { NodeId } from '@/lib/litegraph/src/LGraphNode'
|
||||
import type { RerouteId } from '@/lib/litegraph/src/Reroute'
|
||||
@@ -72,7 +74,11 @@ export class LinkConnectorAdapter {
|
||||
beginFromInput(
|
||||
nodeId: NodeId,
|
||||
inputIndex: number,
|
||||
opts?: { moveExisting?: boolean; fromRerouteId?: RerouteId }
|
||||
opts?: {
|
||||
fromRerouteId?: RerouteId
|
||||
layout?: SlotLayout
|
||||
moveExisting?: boolean
|
||||
}
|
||||
): void {
|
||||
const node = this.network.getNodeById(nodeId)
|
||||
const input = node?.inputs?.[inputIndex]
|
||||
@@ -81,7 +87,10 @@ export class LinkConnectorAdapter {
|
||||
const fromReroute = this.network.getReroute(opts?.fromRerouteId)
|
||||
|
||||
if (opts?.moveExisting) {
|
||||
this.linkConnector.moveInputLink(this.network, input)
|
||||
const startPoint: Point | undefined = opts.layout
|
||||
? [opts.layout.position.x, opts.layout.position.y]
|
||||
: undefined
|
||||
this.linkConnector.moveInputLink(this.network, input, { startPoint })
|
||||
} else {
|
||||
this.linkConnector.dragNewFromInput(
|
||||
this.network,
|
||||
|
||||
@@ -671,7 +671,8 @@ export function useSlotLinkInteraction({
|
||||
})
|
||||
} else {
|
||||
activeAdapter.beginFromInput(localNodeId, index, {
|
||||
moveExisting: shouldMoveExistingInput
|
||||
moveExisting: shouldMoveExistingInput,
|
||||
layout
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user