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

Conversation

misterpekert
Copy link
Contributor

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any feature but make things better)

@@ -10,6 +10,7 @@ export interface TreeNode {
hasChildren?: boolean
matchesFilter?: boolean
indeterminate?: boolean
children: TreeNode[]
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Collaborator

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 || []) }
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.

@asvae asvae self-requested a review June 12, 2023 10:08
- fix getFilteredNodes method so it correctly filters child nodes.
@asvae asvae force-pushed the fix#3059/tree-view-filtering branch from 3206212 to ea687a8 Compare June 19, 2023 16:26
Copy link
Member

@asvae asvae left a 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) => {
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).

@m0ksem m0ksem removed their request for review June 19, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filtering for the complex tree structures doesn't work as expected.
4 participants