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

Tree / TreeSelect: no initial selection of node with empty key #16494

Open
perceptron8 opened this issue Oct 4, 2024 · 1 comment · May be fixed by #16495
Open

Tree / TreeSelect: no initial selection of node with empty key #16494

perceptron8 opened this issue Oct 4, 2024 · 1 comment · May be fixed by #16495
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@perceptron8
Copy link

perceptron8 commented Oct 4, 2024

Describe the bug

Initial selection breaks when node's key is empty string.

Reproducer

https://stackblitz.com/edit/tz94ei-dk7k5x?file=src%2Fapp%2Ftree-controlled-demo.html

PrimeNG version

17.18.11

Steps to reproduce the behavior

See reproducer

Expected behavior

Roots of both trees should be selected.

@perceptron8 perceptron8 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 4, 2024
@perceptron8 perceptron8 changed the title Tree / TreeSelect: no initial selection for node with empty key Tree / TreeSelect: no initial selection of node with empty key Oct 4, 2024
@perceptron8
Copy link
Author

Here's reproducer, just in case if stackblitz.com becomes unavailable:

  • tree-controlled-demo.ts:
import { Component } from '@angular/core';
import { TreeSelectModule } from 'primeng/treeselect';

@Component({
    selector: 'tree-controlled-demo',
    templateUrl: './tree-controlled-demo.html',
    standalone: true,
    imports: [TreeSelectModule]
})
export class TreeControlledDemo {
    public root = {key: '', label: '(root)'};
}
  • tree-controlled-demo.html:
Same instance (selection works fine):
<p-tree selectionMode="single" [value]="[root]" [selection]="root" />

Same key (selection doesn't work):
<p-tree selectionMode="single" [value]="[root]" [selection]="{key: root.key, label: root.label}"  />
`

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

Successfully merging a pull request may close this issue.

1 participant