fix(editor): Delete all connections of nodes with multiple ones when removed from canvas (#15713)

This commit is contained in:
Daria
2025-05-27 13:43:30 +03:00
committed by GitHub
parent 3223f52bbf
commit c4ea7578fe
2 changed files with 79 additions and 2 deletions

View File

@@ -109,6 +109,7 @@ import type { CanvasLayoutEvent } from './useCanvasLayout';
import { chatEventBus } from '@n8n/chat/event-buses';
import { isChatNode } from '@/components/CanvasChat/utils';
import { useLogsStore } from '@/stores/logs.store';
import { cloneDeep } from 'lodash-es';
type AddNodeData = Partial<INodeUi> & {
type: string;
@@ -1122,7 +1123,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
);
for (const nodeName of checkNodes) {
const node = workflowsStore.nodesByName[nodeName];
if (node.position[0] < sourceNode.position[0]) {
if (!node || !sourceNode || node.position[0] < sourceNode.position[0]) {
continue;
}
@@ -1210,7 +1211,7 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
historyStore.startRecordingUndo();
}
const connections = workflowsStore.workflow.connections;
const connections = cloneDeep(workflowsStore.workflow.connections);
for (const nodeName of Object.keys(connections)) {
const node = workflowsStore.getNodeByName(nodeName);
if (!node) {