fix(subflow): remove all edges when removing a block from a subflow (#1003)

This commit is contained in:
Waleed Latif
2025-08-18 00:21:26 -07:00
committed by GitHub
parent 5c16e7d390
commit fdb8256468

View File

@@ -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 })