-
Notifications
You must be signed in to change notification settings - Fork 337
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
base: develop
Are you sure you want to change the base?
Fix(TreeView filtering): #3429
Conversation
@@ -10,6 +10,7 @@ export interface TreeNode { | |||
hasChildren?: boolean | |||
matchesFilter?: boolean | |||
indeterminate?: boolean | |||
children: TreeNode[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be required, see #3077.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, okay. I made it optional. But now I think that we probably need different 'Types' for nodes. The first type is for user data, 2nd type is for our internal node structure. buildTree
method always returns a node with the children
property, but we definitely shouldn't force users to put empty arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User tree node item I would assume should be generic on item type https://blog.vuejs.org/posts/vue-3-3#generic-components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a separate big task for vue generic components support. I'd combine it with moving to script setup with slots and events types.
@@ -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 || []) } |
There was a problem hiding this comment.
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.
- fix getFilteredNodes method so it correctly filters child nodes.
3206212
to
ea687a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have another go at that. Doesn't look good.
@@ -161,7 +161,7 @@ const useTreeView: UseTreeViewFunc = (props, emit) => { | |||
}) | |||
|
|||
const getFilteredNodes = (nodes: TreeNode[]): TreeNode[] => nodes.slice().filter((node) => { |
There was a problem hiding this comment.
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.
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).
closes Filtering for the complex tree structures doesn't work as expected. #3059
Types of changes