CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)
https://angular2-tree.readme.io/docs
MIT License
1.09k stars 488 forks source link

Large tree load with virtualScroll and isExpanded results in browser crash #923

Open binerdy opened 3 years ago

binerdy commented 3 years ago

Minimal reproduction of the bug/regression with instructions:

Stackblitz Reproduction

If you only go 3 levels deep the tree can load.

Versions of Angular Tree Component, Angular, Node, affected browser(s) and operating system(s):

10.0.4

Other information:

In tree-node.model.ts the method _calculateExpandedNodes uses Object.assign for every node that should be expanded. Doing it on every call is quite expensive. My suggestion would be to use extendObservable as the mobx documentation recommends. Then when all expandedNodeIds are known we can apply the expansive Object.assign once to update the reference so that the mobx can detect the change and react to it accordingly.

this.expandedNodeIds = Object.assign({}, this.expandedNodeIds, { [startNode.id]: true }

I would be willing to submit a PR to fix this issue