From cdb45484aab395e25ee8cbcbf90e03934c0fe89a Mon Sep 17 00:00:00 2001 From: "Ricardo M." Date: Fri, 17 Jan 2025 20:52:39 +0100 Subject: [PATCH] fix(Canvas): DnD related logs --- .../src/components/Visualization/Canvas/Canvas.tsx | 12 ++++++++++-- .../Visualization/Custom/Node/CustomNode.tsx | 5 ++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/Visualization/Canvas/Canvas.tsx b/packages/ui/src/components/Visualization/Canvas/Canvas.tsx index c044715df..8fd2ba68f 100644 --- a/packages/ui/src/components/Visualization/Canvas/Canvas.tsx +++ b/packages/ui/src/components/Visualization/Canvas/Canvas.tsx @@ -90,8 +90,16 @@ export const Canvas: FunctionComponent> = ({ enti }, }; - controller.fromModel(model, false); - setInitialized(true); + if (!initialized) { + controller.fromModel(model, false); + setInitialized(true); + return; + } + + requestAnimationFrame(() => { + controller.fromModel(model, true); + controller.getGraph().layout(); + }); }, [controller, entities, visibleFlows]); const handleSelection = useCallback((selectedIds: string[]) => { diff --git a/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx b/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx index cc09749c6..7ca9142f2 100644 --- a/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx +++ b/packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx @@ -114,7 +114,10 @@ const CustomNodeInner: FunctionComponent = observer( nodes: [], edges: [], }); - entitiesContext.updateEntitiesFromCamelResource(); + + requestAnimationFrame(() => { + entitiesContext.updateEntitiesFromCamelResource(); + }); } else { // Show all edges after dropping element