TreeTable: Selection of a node results in the selection of another node under a different parent if data is the same #14536
Labels
Status: Needs Triage
Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Describe the bug
When if two nodes have the same data values (but are not the same instance), and one of them is selected, then the the other node will also be selected.
Environment
Windows 10, but duplicated in stackblitz
Reproducer
https://stackblitz.com/edit/f13fae?file=src%2Fapp%2Fdemo%2Ftree-table-selection-checkbox-demo.html
Angular version
17.0.8
PrimeNG version
17.3.2
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
v20.10.0
Browser(s)
Microsoft Edge for Business Version 120.0.2210.121 (Official build) (64-bit)
Steps to reproduce the behavior
The reproducer is a clone of the Checkbox Selection example: https://primeng.org/treetable#checkbox, however, I got similar results with the multiselect example. I duplicated the Angular data as Angular2 in NodeService.getFileSystemNodesData(), and changed the size of the cli.app child node.
Note that while node "Angular2" was never selected, some of its children were, in addition to those of "Angular". It appears that this is because the children's data are equivalent. The "cli.app" in "Angular2" was not selected because I modified its attributes to not match those of "cli.app" under "Angular".
I thought that including rowTrackBy might fix the problem. The documentation for rowTrackBy states:
However, while the rowTrackBy function is getting called, it had no effect on the outcome of the select.
I also tried adding an explicit key attribute to the node. It made no difference.
Possible Workaround: Adding a unique key to the data. This is ugly,but should work.
This may be related to #10228, which was closed in spite of the fact that the op indicated that the described solution had nothing to do with editing. But I couldn't run that reproducer to confirm.
Expected behavior
When you select a node in the treetable, other nodes that are not children of that node should not be selected.
The text was updated successfully, but these errors were encountered: