File tree 1 file changed +14
-1
lines changed
packages/client/src/components
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -356,7 +356,7 @@ export default function TreeView({
356
356
}
357
357
onChecked ( ids , isChecked ) ;
358
358
if ( isChecked && item . parentId ) {
359
- const parent = data . find ( ( i ) => i . node . id === item . parentId ) ;
359
+ const parent = findTreeNodeRecursive ( data , item . parentId ) ;
360
360
if ( parent ?. radioFolder ) {
361
361
// Find and hide any visible siblings and their children
362
362
const siblings = parent . children . filter (
@@ -684,3 +684,16 @@ export function overlayLayerFragmentsToTreeItems(
684
684
}
685
685
return items ;
686
686
}
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
+ }
You can’t perform that action at this time.
0 commit comments