Nodes connection after deleting a node with edge connected bug fixed
This commit is contained in:
parent
8adc3f203f
commit
0e4bb1bc1d
3 changed files with 6 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ export function TypesProvider({ children }:{children:ReactNode}) {
|
||||||
reactFlowInstance.setNodes(
|
reactFlowInstance.setNodes(
|
||||||
reactFlowInstance.getNodes().filter((n:Node) => n.id !== idx)
|
reactFlowInstance.getNodes().filter((n:Node) => n.id !== idx)
|
||||||
);
|
);
|
||||||
|
reactFlowInstance.setEdges(reactFlowInstance.getEdges().filter((ns) => ns.source !== idx && ns.target !== idx));
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<typesContext.Provider
|
<typesContext.Provider
|
||||||
|
|
|
||||||
|
|
@ -155,6 +155,10 @@ export default function FlowPage({ flow }:{flow:FlowType}) {
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
const onDelete = (mynodes) => {
|
||||||
|
setEdges(edges.filter((ns) => !nodes.some((n) => ns.source === n.id || ns.target === n.id)));
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full" ref={reactFlowWrapper}>
|
<div className="w-full h-full" ref={reactFlowWrapper}>
|
||||||
{Object.keys(types).length > 0 ? (
|
{Object.keys(types).length > 0 ? (
|
||||||
|
|
@ -174,6 +178,7 @@ export default function FlowPage({ flow }:{flow:FlowType}) {
|
||||||
connectionLineComponent={ConnectionLineComponent}
|
connectionLineComponent={ConnectionLineComponent}
|
||||||
onDragOver={onDragOver}
|
onDragOver={onDragOver}
|
||||||
onDrop={onDrop}
|
onDrop={onDrop}
|
||||||
|
onNodesDelete={onDelete}
|
||||||
>
|
>
|
||||||
<Background className="dark:bg-gray-900"/>
|
<Background className="dark:bg-gray-900"/>
|
||||||
<Controls className="[&>button]:text-black [&>button]:dark:bg-gray-800 hover:[&>button]:dark:bg-gray-700 [&>button]:dark:text-gray-400 [&>button]:dark:fill-gray-400 [&>button]:dark:border-gray-600">
|
<Controls className="[&>button]:text-black [&>button]:dark:bg-gray-800 hover:[&>button]:dark:bg-gray-700 [&>button]:dark:text-gray-400 [&>button]:dark:fill-gray-400 [&>button]:dark:border-gray-600">
|
||||||
|
|
|
||||||
|
|
@ -315,7 +315,6 @@ export function isValidConnection(
|
||||||
{ source, target, sourceHandle, targetHandle }:Connection,
|
{ source, target, sourceHandle, targetHandle }:Connection,
|
||||||
reactFlowInstance:ReactFlowInstance
|
reactFlowInstance:ReactFlowInstance
|
||||||
) {
|
) {
|
||||||
console.log(target)
|
|
||||||
if (
|
if (
|
||||||
sourceHandle.split('|')[0] === targetHandle.split("|")[0] ||
|
sourceHandle.split('|')[0] === targetHandle.split("|")[0] ||
|
||||||
sourceHandle.split('|').slice(2).some((t) => t === targetHandle.split("|")[0]) ||
|
sourceHandle.split('|').slice(2).some((t) => t === targetHandle.split("|")[0]) ||
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue