feat: 拖动到循环体节点连线断开

This commit is contained in:
zhanghao 2026-08-07 16:41:38 +08:00
parent dd31fbaef3
commit add482aee2

View File

@ -791,10 +791,21 @@ export const createFlowFacade = (store) => {
const group = store.findNode(groupId);
const child = store.findNode(childId);
if (!group || !child || GROUP_TYPES.has(child.data.flowType)) return;
const previousParentId = child.parentNode || child.data?.properties?.parentId;
const graph = facade.getGraphData();
const groupData = graph.nodes.find((node) => node.id === groupId);
const childData = graph.nodes.find((node) => node.id === childId);
if (!groupData || !childData) return;
// 节点从循环体外进入循环体后,原连线的两端已处于不同执行作用域,必须全部断开。
// 在重新渲染父子结构前直接过滤图数据,可保证入边、出边和层级变更在同一次更新中完成。
const enteringLoop = group.data.flowType === "loop" && previousParentId !== groupId;
if (enteringLoop) {
graph.edges = graph.edges.filter((edge) => (
edge.sourceNodeId !== childId && edge.targetNodeId !== childId
));
}
groupData.children = Array.from(new Set([...(groupData.children || []), childId]));
childData.properties = { ...(childData.properties || {}), parentId: groupId };
if (dropCenter) {