mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 07:00:23 +00:00
Fix: Shift+Click+Drag from outputs with Subgraph outputs (#5115)
* fix: Handle shift+click+drag to collectively move outputs when connected to a subgraph output * [Bug]: Multiple issues with shift-dragging links to subgraph output node input slots Fixes #4877 When shift clicking, ignore links that are no longer present in the subgraph. * cleanup: Utility function to filter for relevant outputs when shift+clicking * cleanup: Remove some pieces that are redundant in this context. Different enough to warrant not extracting a common function yet.
This commit is contained in:
@@ -36,6 +36,7 @@ import type {
|
||||
INodeSlot,
|
||||
INodeSlotContextItem,
|
||||
ISlotType,
|
||||
LinkNetwork,
|
||||
LinkSegment,
|
||||
NullableProperties,
|
||||
Point,
|
||||
@@ -2575,16 +2576,27 @@ export class LGraphCanvas
|
||||
} else if (!node.flags.collapsed) {
|
||||
const { inputs, outputs } = node
|
||||
|
||||
function hasRelevantOutputLinks(
|
||||
output: INodeOutputSlot,
|
||||
network: LinkNetwork
|
||||
): boolean {
|
||||
const outputLinks = [
|
||||
...(output.links ?? []),
|
||||
...[...(output._floatingLinks ?? new Set())]
|
||||
]
|
||||
return outputLinks.some(
|
||||
(linkId) =>
|
||||
typeof linkId === 'number' && network.getLink(linkId) !== undefined
|
||||
)
|
||||
}
|
||||
|
||||
// Outputs
|
||||
if (outputs) {
|
||||
for (const [i, output] of outputs.entries()) {
|
||||
const link_pos = node.getOutputPos(i)
|
||||
if (isInRectangle(x, y, link_pos[0] - 15, link_pos[1] - 10, 30, 20)) {
|
||||
// Drag multiple output links
|
||||
if (
|
||||
e.shiftKey &&
|
||||
(output.links?.length || output._floatingLinks?.size)
|
||||
) {
|
||||
if (e.shiftKey && hasRelevantOutputLinks(output, graph)) {
|
||||
linkConnector.moveOutputLink(graph, output)
|
||||
this.#linkConnectorDrop()
|
||||
return
|
||||
|
||||
@@ -314,6 +314,27 @@ export class LinkConnector {
|
||||
this.outputLinks.push(link)
|
||||
|
||||
try {
|
||||
if (link.target_id === SUBGRAPH_OUTPUT_ID) {
|
||||
if (!(network instanceof Subgraph)) {
|
||||
console.warn(
|
||||
'Subgraph output link found in non-subgraph network.'
|
||||
)
|
||||
continue
|
||||
}
|
||||
|
||||
const output = network.outputs.at(link.target_slot)
|
||||
if (!output) throw new Error('No subgraph output found for link.')
|
||||
|
||||
const renderLink = new ToOutputFromIoNodeLink(
|
||||
network,
|
||||
network.outputNode,
|
||||
output
|
||||
)
|
||||
renderLink.fromDirection = LinkDirection.NONE
|
||||
renderLinks.push(renderLink)
|
||||
|
||||
continue
|
||||
}
|
||||
const renderLink = new MovingOutputLink(
|
||||
network,
|
||||
link,
|
||||
|
||||
Reference in New Issue
Block a user