refa: improve tree clustering (#17285)

This commit is contained in:
buua436
2026-07-23 17:49:13 +08:00
committed by GitHub
parent 7b64e4dc5d
commit d4a8c91f3c
6 changed files with 195 additions and 74 deletions

View File

@@ -142,7 +142,7 @@ const TreeItem = React.forwardRef<HTMLDivElement, TreeItemProps>(
<ul>
{data.map((item) => (
<li key={item.id}>
{item.children ? (
{item.children && item.children.length > 0 ? (
<TreeNode
item={item}
selectedItemId={selectedItemId}

View File

@@ -48,6 +48,11 @@ function buildTreeDataItems(
for (const relation of relations) {
if (!relationTypes.includes(relation.type ?? '')) continue;
// Self-referencing relation (same entity as its own child) creates
// an infinite recursion in the tree renderer. This is a backend
// data integrity issue (duplicate entity names) but we defend
// against it in the frontend so the UI never hangs.
if (relation.from === relation.to) continue;
const parent = map.get(relation.from);
const child = map.get(relation.to);