mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-10 07:27:57 -05:00
fix(subflow): remove all edges when removing a block from a subflow (#1003)
This commit is contained in:
@@ -352,26 +352,13 @@ const WorkflowContent = React.memo(() => {
|
||||
// Remove parent-child relationship while preserving absolute position
|
||||
updateNodeParent(blockId, null)
|
||||
|
||||
// Clean up any edges that now cross container boundaries for this block
|
||||
const rfNodes = getNodes()
|
||||
const sourceOrTargetEdges = edgesForDisplay.filter(
|
||||
// Remove all edges connected to this block
|
||||
const connectedEdges = edgesForDisplay.filter(
|
||||
(e) => e.source === blockId || e.target === blockId
|
||||
)
|
||||
|
||||
sourceOrTargetEdges.forEach((edge) => {
|
||||
const sourceNode = rfNodes.find((n) => n.id === edge.source)
|
||||
const targetNode = rfNodes.find((n) => n.id === edge.target)
|
||||
const sourceParent = sourceNode?.parentId
|
||||
const targetParent = targetNode?.parentId
|
||||
|
||||
const crossesBoundary =
|
||||
(sourceParent && !targetParent) ||
|
||||
(!sourceParent && targetParent) ||
|
||||
(sourceParent && targetParent && sourceParent !== targetParent)
|
||||
|
||||
if (crossesBoundary) {
|
||||
removeEdge(edge.id)
|
||||
}
|
||||
connectedEdges.forEach((edge) => {
|
||||
removeEdge(edge.id)
|
||||
})
|
||||
} catch (err) {
|
||||
logger.error('Failed to remove from subflow', { err })
|
||||
|
||||
Reference in New Issue
Block a user