Skip to content

Commit d9485d3

Browse files
Fix radio folder behavior when nested
1 parent 472cd4f commit d9485d3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/client/src/components/TreeView.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ export default function TreeView({
356356
}
357357
onChecked(ids, isChecked);
358358
if (isChecked && item.parentId) {
359-
const parent = data.find((i) => i.node.id === item.parentId);
359+
const parent = findTreeNodeRecursive(data, item.parentId);
360360
if (parent?.radioFolder) {
361361
// Find and hide any visible siblings and their children
362362
const siblings = parent.children.filter(
@@ -684,3 +684,16 @@ export function overlayLayerFragmentsToTreeItems(
684684
}
685685
return items;
686686
}
687+
688+
function findTreeNodeRecursive(data: TreeNode[], id: string): TreeNode | null {
689+
for (const node of data) {
690+
if (node.node.id === id) {
691+
return node;
692+
}
693+
const found = findTreeNodeRecursive(node.children, id);
694+
if (found) {
695+
return found;
696+
}
697+
}
698+
return null;
699+
}

0 commit comments

Comments
 (0)