From 46fc843760a4bbfc94bf9fbfa3e89db10825c3f4 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Mon, 16 Oct 2023 15:23:13 -0300 Subject: [PATCH] fix(reactflowUtils.ts): update updateEdgesIds function to correctly update targetHandle proxy ids and stringify targetHandle fix(reactflowUtils.ts): update expandGroupNode function to correctly iterate over flowEdges instead of ReactFlowInstance.getEdges() to redirect edges to correct proxy node --- src/frontend/src/utils/reactflowUtils.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/utils/reactflowUtils.ts b/src/frontend/src/utils/reactflowUtils.ts index f02c1a112..20f4e3e50 100644 --- a/src/frontend/src/utils/reactflowUtils.ts +++ b/src/frontend/src/utils/reactflowUtils.ts @@ -918,7 +918,16 @@ function updateProxyIdsOnTemplate( }); } -function updateEdgesIds(edges: Edge[], idsMap: { [key: string]: string }) {} +function updateEdgesIds(edges: Edge[], idsMap: { [key: string]: string }) { + edges.forEach((edge) => { + let targetHandle: targetHandleType = edge.data.targetHandle; + if (targetHandle.proxy && idsMap[targetHandle.proxy!.id]) { + targetHandle.proxy!.id = idsMap[targetHandle.proxy!.id]; + } + edge.data.targetHandle = targetHandle; + edge.targetHandle = scapedJSONStringfy(targetHandle); + }); +} export function expandGroupNode( groupNode: NodeDataType, @@ -936,7 +945,7 @@ export function expandGroupNode( console.log(gEdges); //redirect edges to correct proxy node let updatedEdges: Edge[] = []; - ReactFlowInstance.getEdges().forEach((edge) => { + flowEdges.forEach((edge) => { let newEdge = _.cloneDeep(edge); if (newEdge.target === groupNode.id) { const targetHandle: targetHandleType = newEdge.data.targetHandle;