Skip to content

Commit

Permalink
Fix(TreeView filtering):
Browse files Browse the repository at this point in the history
- fix getFilteredNodes method so it correctly filters child nodes.
  • Loading branch information
misterpekert committed May 17, 2023
1 parent 93ecea8 commit 44be413
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const useTreeView: UseTreeViewFunc = (props, emit) => {
})

const getFilteredNodes = (nodes: TreeNode[]): TreeNode[] => nodes.slice().filter((node) => {
if (node.hasChildren) { getFilteredNodes(getChildren(node)) }
if (node.hasChildren) { node.children = getFilteredNodes(node.children) }

return node.matchesFilter ? node : false
})
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/va-tree-view/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface TreeNode {
hasChildren?: boolean
matchesFilter?: boolean
indeterminate?: boolean
children: TreeNode[]
[key: string]: any
}

Expand Down

0 comments on commit 44be413

Please sign in to comment.