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

TreeSelect: Unexpected value with selectionMode multiple or checkbox #16476

Open
lfpraca opened this issue Oct 2, 2024 · 0 comments
Open

TreeSelect: Unexpected value with selectionMode multiple or checkbox #16476

lfpraca opened this issue Oct 2, 2024 · 0 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@lfpraca
Copy link

lfpraca commented Oct 2, 2024

Describe the bug

The documentation for TreeSelect says that when using selectionMode multiple, the value binding should be a key-value pair, however, the component does not understand input in this format, having nothing selected when passing an input such as

  selectedNodes: any = {
    '0-0-0': true,
    '0-0-1': true,
  };

where all keys are valid keys for the nodes passed as options, instead, an error is thrown when trying to interact with the component: TypeError: ({'0-0-0':true, '0-0-1':true}) is not iterable.

The value that is actually returned and expected by the component is in the format contains data, icon, key, label, style, parent and children, which is not only unexpected considering the documentation but is also much harder to work with when passing data into the component, especially considering that redundant information such as the label need to be passed into the component for it to properly render.

In the checkbox selectionMode this is paticularly a problem as the information the component needs to render the partial checkbox is impossible to pass in, as shown in the stackblitz example, where the same data passed out from the component does not cause the partial checkboxes to render on the component when receiving such data.

Environment

I am using the stackblitz environment linked by the documentation examples.

Reproducer

https://stackblitz.com/edit/oi53ur-zt5quo?file=src%2Fapp%2Ftree-select-checkbox-demo.ts

Angular version

18.2.7

PrimeNG version

17.18.11

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.20.3

Browser(s)

No response

Steps to reproduce the behavior

  1. Select any item from the options in the tree select.
  2. See the console.log output that shows the unexpected value for the selectedNodes.
  3. Select any child option with siblings without selecting the parent.
  4. See that the parent does not get rendered with partial selection while there is a second treeSelect, which causes the outputted value to be fed back to the component.
  5. Delete one of the treeSelects, leaving just one.
  6. Select again any child option with siblings without selecting the parent.
  7. See that the parent does get properly rendered with the partial selection checkbox as long as there is no input to the component.

Expected behavior

  • Expected the output to follow the format specified in the documentation.
  • Expected the input to work when following the format specified in the documentation.
  • Expected the value outputted by the component to cause the same render when inputted to the component.
@lfpraca lfpraca added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

1 participant