From a6b6857e372863844ca47933e9b2bd01edc6f15a Mon Sep 17 00:00:00 2001 From: AustinMroz Date: Thu, 15 Jan 2026 20:36:39 -0800 Subject: [PATCH] Fix copypasted primitives inside subgraphs (#8094) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copying a subgraph which contains primitive nodes would cause the primitives to fail to initialize. This was caused because they did not have their `onGraphConfigured` and `onAfterGraphConfigured` callbacks applied. There's already a copy of `forEachNode` in `@/utils/graphTraversalUtil.ts`, but the method is small and I want to avoid litegraph referencing outside code. See also #6606, where a similar fix was needed ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8094-Fix-copypasted-primitives-inside-subgraphs-2ea6d73d365081f189f1ea4c9248f5ed) by [Unito](https://www.unito.io) --- src/lib/litegraph/src/LGraphCanvas.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/litegraph/src/LGraphCanvas.ts b/src/lib/litegraph/src/LGraphCanvas.ts index 7dee812fc..3129324e3 100644 --- a/src/lib/litegraph/src/LGraphCanvas.ts +++ b/src/lib/litegraph/src/LGraphCanvas.ts @@ -8,6 +8,7 @@ import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMuta import { layoutStore } from '@/renderer/core/layout/store/layoutStore' import { LayoutSource } from '@/renderer/core/layout/types' import { removeNodeTitleHeight } from '@/renderer/core/layout/utils/nodeSizeUtil' +import { forEachNode } from '@/utils/graphTraversalUtil' import { CanvasPointer } from './CanvasPointer' import type { ContextMenu } from './ContextMenu' @@ -4057,6 +4058,8 @@ export class LGraphCanvas implements CustomEventDispatcher layoutStore.batchUpdateNodeBounds(newPositions) this.selectItems(created) + forEachNode(graph, (n) => n.onGraphConfigured?.()) + forEachNode(graph, (n) => n.onAfterGraphConfigured?.()) graph.afterChange() this.emitAfterChange()