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

Closed
perceptron8 opened this issue Oct 4, 2024 · 1 comment · Fixed by #16495
Closed

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

perceptron8 opened this issue Oct 4, 2024 · 1 comment · Fixed by #16495
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working v18-port
Milestone

Comments

@perceptron8
Copy link
Contributor

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
Contributor 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}"  />
`

@mertsincan mertsincan added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working 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 18, 2024
@mertsincan mertsincan added this to the 17.18.13 milestone Nov 18, 2024
@mertsincan mertsincan moved this to Done in PrimeNG Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working v18-port
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants