From 9761be2c00221f9f594b7fc8585063876861ab67 Mon Sep 17 00:00:00 2001 From: Shivam Gupta Date: Wed, 8 Jan 2025 16:24:27 +0530 Subject: [PATCH] Fix(DND): Fix console errors related to DND --- .../Visualization/Custom/Node/CustomNode.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx b/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx index bbded3312..843ab71e7 100644 --- a/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx +++ b/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx @@ -106,15 +106,21 @@ const CustomNode: FunctionComponent = observer( } }, end(dropResult, monitor) { - const graph = controller.getGraph(); - // Show all edges after dropping - graph.getEdges().forEach((edge) => edge.setVisible(true)); - if (monitor.didDrop() && dropResult) { const draggedNodePath = element.getData().vizNode.data.path; dropResult.getData()?.vizNode?.moveNodeTo(draggedNodePath); + // Set an empty model to clear the graph + controller.fromModel({ + nodes: [], + edges: [], + }); entitiesContext.updateEntitiesFromCamelResource(); } else { + // Show all edges after dropping + controller + .getGraph() + .getEdges() + .forEach((edge) => edge.setVisible(true)); controller.getGraph().layout(); } },