You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Component,OnInit}from'@angular/core';import{NodeService}from'./nodeservice';import{TreeNode}from'primeng/api';
@Component({selector: 'app-root',templateUrl: './app.component.html'})exportclassAppComponent{files1: TreeNode[];files2: TreeNode[];constructor(privatenodeService: NodeService){}ngOnInit(){this.nodeService.getFiles().then(files=>{// If you pass expanded: true in here,// children are duplicatedthis.files1=[{ ...files[0],expanded: true}]});this.nodeService.getFiles().then(files=>this.files2=files);}expandAll(){this.files2.forEach(node=>{this.expandRecursive(node,true);});}collapseAll(){this.files2.forEach(node=>{this.expandRecursive(node,false);});}privateexpandRecursive(node:TreeNode,isExpand:boolean){node.expanded=isExpand;if(node.children){node.children.forEach(childNode=>{this.expandRecursive(childNode,isExpand);});}}}
Copy and paste the following code to app.component.ts
import{Component,OnInit}from'@angular/core';import{NodeService}from'./nodeservice';import{TreeNode}from'primeng/api';
@Component({selector: 'app-root',templateUrl: './app.component.html'})exportclassAppComponent{files1: TreeNode[];files2: TreeNode[];constructor(privatenodeService: NodeService){}ngOnInit(){this.nodeService.getFiles().then(files=>{// If you pass expanded: true in here,// children are duplicatedthis.files1=[{ ...files[0],expanded: true}]});this.nodeService.getFiles().then(files=>this.files2=files);}expandAll(){this.files2.forEach(node=>{this.expandRecursive(node,true);});}collapseAll(){this.files2.forEach(node=>{this.expandRecursive(node,false);});}privateexpandRecursive(node:TreeNode,isExpand:boolean){node.expanded=isExpand;if(node.children){node.children.forEach(childNode=>{this.expandRecursive(childNode,isExpand);});}}}
Expected behavior
It should render as the input value, not duplicated children
The text was updated successfully, but these errors were encountered:
Describe the bug
In the primeng document page example, https://stackblitz.com/edit/primeng-tree-demo?file=src%2Fapp%2Fapp.component.ts, I upgrade primeng to 14.0.0-rc.1 and change
expanded
property totrue
and it renders unexpected children.Environment
I test it on https://stackblitz.com/edit/primeng-tree-demo?file=src%2Fapp%2Fapp.component.ts which is from primeng documentation website (https://primefaces.org/primeng/tree)
Reproducer
No response
Angular version
14.0.3
PrimeNG version
14.0.0-rc.1
Build / Runtime
Angular CLI App
Language
TypeScript
Node version (for AoT issues node --version)
16.4.2
Browser(s)
Chrome 103.0.5060.53
Steps to reproduce the behavior
app.component.ts
Expected behavior
It should render as the input value, not duplicated children
The text was updated successfully, but these errors were encountered: