fix(web): iteration/loop toFront

This commit is contained in:
zhaoying
2026-04-09 22:13:52 +08:00
parent 27e9f9968d
commit 84b1a95313
2 changed files with 36 additions and 0 deletions

View File

@@ -61,6 +61,20 @@ const CaseList: FC<CaseListProps> = ({
const { t } = useTranslation();
const form = Form.useFormInstance();
const bringLoopChildrenToFront = (cell: any) => {
const type = cell?.getData()?.type;
if ((type !== 'loop' && type !== 'iteration') || !graphRef?.current) return;
const cycleId = cell.getData().id;
graphRef.current.getEdges().forEach((edge: any) => {
const src = graphRef.current?.getCellById(edge.getSourceCellId());
const tgt = graphRef.current?.getCellById(edge.getTargetCellId());
if (src?.getData()?.cycle === cycleId || tgt?.getData()?.cycle === cycleId) edge.toFront();
});
graphRef.current.getNodes().forEach((n: any) => {
if (n.getData()?.cycle === cycleId) n.toFront();
});
};
// Recalculate node height and port Y positions without rebuilding ports
const updateNodeLayout = (cases: any[]) => {
if (!selectedNode || !graphRef?.current) return;
@@ -141,6 +155,8 @@ const CaseList: FC<CaseListProps> = ({
}
sourceCell.toFront()
selectedNode.toFront()
bringLoopChildrenToFront(sourceCell)
bringLoopChildrenToFront(selectedNode)
graphRef.current?.removeCell(edge);
return;
}
@@ -186,7 +202,9 @@ const CaseList: FC<CaseListProps> = ({
...edgeAttrs
});
selectedNode.toFront()
bringLoopChildrenToFront(selectedNode)
targetCell.toFront()
bringLoopChildrenToFront(targetCell)
}
}

View File

@@ -25,6 +25,20 @@ const CategoryList: FC<CategoryListProps> = ({ parentName, selectedNode, graphRe
const form = Form.useFormInstance();
const formValues = Form.useWatch([parentName], form);
const bringLoopChildrenToFront = (cell: any) => {
const type = cell?.getData()?.type;
if ((type !== 'loop' && type !== 'iteration') || !graphRef?.current) return;
const cycleId = cell.getData().id;
graphRef.current.getEdges().forEach((edge: any) => {
const src = graphRef.current?.getCellById(edge.getSourceCellId());
const tgt = graphRef.current?.getCellById(edge.getTargetCellId());
if (src?.getData()?.cycle === cycleId || tgt?.getData()?.cycle === cycleId) edge.toFront();
});
graphRef.current.getNodes().forEach((n: any) => {
if (n.getData()?.cycle === cycleId) n.toFront();
});
};
// Update node ports based on category count changes (add/remove categories)
const updateNodePorts = (caseCount: number, removedCaseIndex?: number) => {
if (!selectedNode || !graphRef?.current) return;
@@ -89,7 +103,9 @@ const CategoryList: FC<CategoryListProps> = ({ parentName, selectedNode, graphRe
...edgeAttrs
});
sourceCell.toFront()
bringLoopChildrenToFront(sourceCell)
selectedNode.toFront()
bringLoopChildrenToFront(selectedNode)
}
return;
}
@@ -122,7 +138,9 @@ const CategoryList: FC<CategoryListProps> = ({ parentName, selectedNode, graphRe
...edgeAttrs
});
selectedNode.toFront()
bringLoopChildrenToFront(selectedNode)
targetCell.toFront()
bringLoopChildrenToFront(targetCell)
}
}
});