Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(TreeView filtering): #3429

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still works incorrectly. Maybe a different issue, but still.

image

I would expect no items to be shown as category is not selectable.

Let's have a small investigation on how tree view should behave on filter, than implement it accordingly. Implementation might cover different behaviours, though I'm pretty sure documentation could have just nodes search (no categories).

if (node.hasChildren) { getFilteredNodes(getChildren(node)) }
if (node.hasChildren) { node.children = getFilteredNodes(node.children || []) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we separate filter and map? Looks very confusing to me.


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