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:
Alexander Brown
2025-08-20 11:22:02 -07:00
committed by GitHub
parent 1e9d4c7c37
commit 4db9e3d7fb
2 changed files with 37 additions and 4 deletions

View File

@@ -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

View File

@@ -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,