diff --git a/webui/src/features/views/ViewsAdminPanel.tsx b/webui/src/features/views/ViewsAdminPanel.tsx index 4f88f71..55412d0 100644 --- a/webui/src/features/views/ViewsAdminPanel.tsx +++ b/webui/src/features/views/ViewsAdminPanel.tsx @@ -1054,10 +1054,12 @@ function SurfaceSelector({ function descendants(surfaceId: string): string[] { const result: string[] = []; + const visited = new Set([surfaceId]); const pending = [...(childrenByParent.get(surfaceId) ?? [])]; while (pending.length) { const child = pending.shift(); - if (!child) continue; + if (!child || visited.has(child.id)) continue; + visited.add(child.id); result.push(child.id); pending.push(...(childrenByParent.get(child.id) ?? [])); } @@ -1065,8 +1067,11 @@ function SurfaceSelector({ } function withAncestors(next: Set, surfaceId: string) { + const visited = new Set([surfaceId]); let current = byId.get(surfaceId); while (current?.parentId) { + if (visited.has(current.parentId)) break; + visited.add(current.parentId); next.add(current.parentId); current = byId.get(current.parentId); }