-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
TreeSelect: Programmatic selection does not propagate #12714
Comments
Is there any update on this? We have 4 levels in our tree and programmatic selection is not propagating. |
I don't see how this would fix the issue, the defaults for both |
FWIW, my workaround was to disable propagation in both directions so that we could take control and implement the propagation logic ourselves. In our specific use case, reimplementing the logic from scratch produced a much simpler implementation than the stock one provided by primeng. That one attempts to cope with dozens of configuration scenarios that weren't valuable for us, and as a result is obscenely complex. While it's frustrating to do, you might find that you are also able to produce something far simpler and more bug-free than PrimeNg's approach. I will note that the choice to have "selection" and "partialSelection" represented in fundamentally different ways (one via a separate selection array and the other via a piece of state recorded on individual nodes) is very strange and made it more frustrating to work with. |
@xanderflood We are facing the same issue. Would you mind sharing your solution through a Gist or creating a PR to resolve this issue? |
@xanderflood, it would be really helpful if you could share your custom code through a Gist. Thanks! |
I faced the same issue, and here is my workaround code to make it work. Thanks. |
+1 |
+1
This doesn't even compile btw (v17).. |
Hi, So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation and try the latest PrimeNG version(v19). If there is no improvement on this, can you open a new issue so we can include it in our roadmap? Thanks a lot for your understanding! |
Incredible, just close ALL open issues (this is just one of many) to be "maybe" fixed 🤯 What instead of just closing this issue, you check the issue? This is still a open, valid bug |
If you still feel the issue hasn’t been resolved, you’re welcome to open a new one and back it up with a pull request. This helps us stay organized and build a clear roadmap. With 1,000–2,000 tickets, it’s tough to track everything, so community contributions through PRs can make a big difference. I think it is better to put some issues on a roadmap rather than letting them get lost. |
Describe the bug
When selecting nodes in a checkbox-based treselect using mouse clicks, the default behavior is to propagate selection up the tree so that ancestors will be either selected or partially selected, as required.
When setting the selection for a tree programmatically the expected behavior is that this propagation would also take place, but it currently does not.
This bug is pretty onerous to work around. Correctly propagating this state manually requires a considerable amount of code, especially if you want to handle all the possible cases, like choosing non-leaf nodes, propagating both up and down, and distinguishing partial- and full-selection (since one is managed by modifying the contents of the node tree itself, and the other is managed by manipulating the actual selection value). The existing implementation of propagation does not seem to be packaged in a way that allows users of the library to easily trigger the existing logic directly, so a manual workaround produces significant code duplication.
Environment
This stackblitz uses Angular v11 and primeng v13, but I experienced the issue originally using v14 of each, and later also using v15 of each. https://stackblitz.com/edit/primeng-treeselect-demo-rddvht?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts,package.json
Reproducer
No response
Angular version
14
PrimeNG version
14
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
18
Browser(s)
No response
Steps to reproduce the behavior
See here: https://stackblitz.com/edit/primeng-treeselect-demo-rddvht?file=src%2Fapp%2Fapp.component.html,src%2Fapp%2Fapp.component.ts,package.json
Expected behavior
Whenver a tree, treeselect, or other related component has its selection modified, even it is being modified programmatically, the configured propagation behavior should be allowed to take place.
The text was updated successfully, but these errors were encountered: