From 0e4bb1bc1d6059b98ccc634be6f9d49abbc60696 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 8 Mar 2023 19:40:40 -0300 Subject: [PATCH] Nodes connection after deleting a node with edge connected bug fixed --- langflow/frontend/src/contexts/typesContext.tsx | 1 + langflow/frontend/src/pages/FlowPage/index.tsx | 5 +++++ langflow/frontend/src/utils.ts | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/langflow/frontend/src/contexts/typesContext.tsx b/langflow/frontend/src/contexts/typesContext.tsx index 664a3dcf6..d20012a84 100644 --- a/langflow/frontend/src/contexts/typesContext.tsx +++ b/langflow/frontend/src/contexts/typesContext.tsx @@ -21,6 +21,7 @@ export function TypesProvider({ children }:{children:ReactNode}) { reactFlowInstance.setNodes( reactFlowInstance.getNodes().filter((n:Node) => n.id !== idx) ); + reactFlowInstance.setEdges(reactFlowInstance.getEdges().filter((ns) => ns.source !== idx && ns.target !== idx)); } return ( { + setEdges(edges.filter((ns) => !nodes.some((n) => ns.source === n.id || ns.target === n.id))); + } return (
@@ -174,6 +178,7 @@ export default function FlowPage({ flow }:{flow:FlowType}) { connectionLineComponent={ConnectionLineComponent} onDragOver={onDragOver} onDrop={onDrop} + onNodesDelete={onDelete} > diff --git a/langflow/frontend/src/utils.ts b/langflow/frontend/src/utils.ts index 3f53b446d..c95f17834 100644 --- a/langflow/frontend/src/utils.ts +++ b/langflow/frontend/src/utils.ts @@ -315,7 +315,6 @@ export function isValidConnection( { source, target, sourceHandle, targetHandle }:Connection, reactFlowInstance:ReactFlowInstance ) { - console.log(target) if ( sourceHandle.split('|')[0] === targetHandle.split("|")[0] || sourceHandle.split('|').slice(2).some((t) => t === targetHandle.split("|")[0]) ||