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(tree): toggle node when filtering mode #7282

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

KumJungMin
Copy link
Contributor

Defect Fixes

How To Resolve

Issue

  • When filtering in the tree, the toggle function doesn't work.
  • Upon investigation, it was found that previously, when filtering, we used node.expanded = true to expand nodes.
  • In this case, the child component would recognize the node.expanded value based on specific conditions and expand the node.
  • However, in this approach, when filtering, the toggle event argument is an empty object
  • Therefore, the toggle function does not work while filtering.

Solution

  • I added filterExpandedKeys to be used when filtering and ensured that this value is used during filtering.
  • When a toggle is requested, I update filterExpandedKeys while filtering, and in other cases, I update expandedKeysState.
if (isFiltering) {
    setFilterExpandedKeys(value);
} else {
    setExpandedKeysState(value);
}

Result

Test Cases:

  1. When filtering, the corresponding node should be expanded.
  2. It should be possible to toggle nodes while in a filtering state.
  3. If a node was toggled before filtering, it should remain expanded after filtering is finished.
2024-10-01.2.54.29.mp4

Copy link

vercel bot commented Oct 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
primereact ⬜️ Ignored (Inspect) Visit Preview Oct 8, 2024 0:26am
primereact-v9 ⬜️ Ignored (Inspect) Visit Preview Oct 8, 2024 0:26am

@melloware melloware added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tree: Collapse Not Working When Nodes Are Filtered
3 participants