primeng icon indicating copy to clipboard operation
primeng copied to clipboard

P-Tree component renders tree too slow in version 17

Open Lautern opened this issue 2 years ago • 3 comments

Describe the bug

P-Tree component renders tree too slow in version 17 on expand when there are more than 1000 children. In version 14 it worked perfectly fine: https://stackblitz.com/edit/primeng-tree-demo-4jcspp?file=src%2Fapp%2Fapp.component.ts In version 17 slow behavior as described above: https://stackblitz.com/edit/hjxyqy?file=src%2Fapp%2Fdemo%2Ftree-basic-demo.ts

Environment

angular 17.0.5 primeng 17.6.0 node 20.0.9

Reproducer

https://stackblitz.com/edit/hjxyqy?file=src%2Fapp%2Fdemo%2Ftree-basic-demo.ts

Angular version

17.0.5

PrimeNG version

17.6.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.0.9

Browser(s)

Chrome, Firefox

Steps to reproduce the behavior

See stackblitz links. Click on expand for Documents and observe how slow children are rendered and the whole browser freezes

Expected behavior

children should be rendered faster (as in version 14)

Lautern avatar Feb 08 '24 11:02 Lautern

To mention, in the case of Primeng 17 in the example there are 900 items, and in the example with Primeng 14 there are 2000 items. And in example with primeng 14 it expands much faster than in example with primeng 17.

MaximSt85 avatar Feb 08 '24 16:02 MaximSt85

Hi,

v14 also load slow as I see in your example, to handle large amount of data please use virtualScroll feature to load items. Here is a basic implementation. https://stackblitz.com/edit/tzszub?file=src%2Fapp%2Fdemo%2Ftree-basic-demo.html,src%2Fapp%2Fdemo%2Ftree-basic-demo.ts

Closing the issue since it can be solved by enabling virtualScroll.

cetincakiroglu avatar Feb 23 '24 07:02 cetincakiroglu

Your example with virtual scroll doesn't show expand all or collapse all. If you enable virtual scroll and use the same code for expand all or collapse all, https://stackblitz.com/edit/habzg8ts?file=src%2Fapp%2Ftree-controlled-demo.html the chevron will update but the tree nodes won't actually expand until you click on one of the items and then they'll all expand. Same for collapse - the chevrons will update but the tree nodes won't collapse until you click one of the items and then they'll all collapse. So the solution to use virtual scroll with expand all / collapse all does not work. I also have the same experience where expanding all the items is much slower after upgrading to a newer version of PrimeNG.

lblu12555 avatar Aug 21 '25 00:08 lblu12555