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

Component: SelectionTree, Bug when selecting something while having filtered value #16792

Open
rickstick-code opened this issue Nov 20, 2024 · 3 comments
Labels
Resolution: Help Wanted Issue or pull request requires extra help and feedback
Milestone

Comments

@rickstick-code
Copy link

Describe the bug

If you use the tree select component with the given filter and you select something the parents get marked as selected. Even though they should be marked as partially selected.

selecttreebug

Environment

Windows 10
Chrome 130.0.6723.117

Reproducer

No response

Angular version

18.2.8

PrimeNG version

17.18.11

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

22.0.0

Browser(s)

Chrome

Steps to reproduce the behavior

Filter for an element, mark it and when you remove the filter it shows the parents as selected. (example in gif)

Expected behavior

The parents should be shown as partially selected. (example in gif)

@rickstick-code rickstick-code added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Nov 20, 2024
@rickstick-code rickstick-code changed the title Component: Title Bug with selection tree Nov 20, 2024
@rickstick-code rickstick-code changed the title Bug with selection tree Component: SelectionTree, Bug when selecting something while having filtered value Nov 20, 2024
@mertsincan mertsincan added this to the 17.18.13 milestone Nov 20, 2024
@mertsincan mertsincan added Resolution: Help Wanted Issue or pull request requires extra help and feedback and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Nov 20, 2024
@mertsincan mertsincan modified the milestones: 17.18.13, Future Nov 20, 2024
Copy link

Due to PrimeNG team's busy roadmap, this issue is available for anyone to work on. Make sure to reference this issue in your pull request. ✨ Thank you for your contribution! ✨

@shaman-apprentice
Copy link
Contributor

@rickstick-code I had the same issue. I thought about contributing a fix. When I digged into the source code, I realized, that key of given node is used. In the TypeScript typing of TreeNode the key?: string property is optional but the docs clearly state that it is mandatory.

Long story short, I added unique keys to my nodes and it works as expected. Maybe it also fixes it for you?

I was tempted to tackle the TypeScript typings, but I guess it "fits" into the current any typings and if I am not mistaken, there are plans for improvements (see here). So I am really excited for upcomming releases 😍

@philproof
Copy link

@shaman-apprentice
Unfortunately that didn't work for me and the fix I put up fixes it, as far as I know, and has been merged but never released. My personal case in my project is that we have objects of nodes with {label: string, key: number}, nested. So more like:
{ label, key, children: [ label, key, children: [ label key ] ] }.sort(...)
So not sure if the nesting is what is causing the issue, but all the keys are unique numbers. If I select something from an unfiltered list, it works as expected. However, filtering on something, like in the example in the initial post in this issue, causes the problem for me the same way. I'm not sure of a workaround until PrimeNG releases this fix or another one. My company is using 17.18 (so a little behind) which is why I put up a fix in v17.18. Also the initial posting is from the same version. Not sure if they still release fixes for that version and propagate up to others or what but still holding for a fix b/c it's breaking filtered selections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Help Wanted Issue or pull request requires extra help and feedback
Projects
Status: Review
Development

No branches or pull requests

4 participants