bug(mat-tree): TreeControl's getChildren is called unexpectedly many times since cdk/material v18.2.0 and is especially problematic with asynchronous actions #30014
Labels
area: cdk/tree
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Is this a regression?
The previous version in which this bug was not present was
18.1.5
Description
I've recently upgraded a project's
@angular/cdk
&@angular/material
packages to 18.2, and I noticed a problem with theTreeControl
whengetChildren
was asynchronous: sometimes it would result in an infinite loop of asynchronous actions; other times, it would perform a very large number of asynchronous actions; previous to 18.2 (18.1.5 was the last version it worked as expected), it would have only started a single asynchronous action per node. This is especially noticeable when the asynchronous action involves some kind of XHR.Looking a bit further into it, I noticed that synchronous
getChildren
calls have also regressed in 18.2.0: there are now a lot more calls to this method than in cdk/material 18.1.5.Reproduction
18.2.X:
StackBlitz link: StackBlitz 18.2.X
Steps to reproduce:
Expected Behavior
There should be exactly 1 call to
getChildren
for each expanded node18.1.X:
StackBlitz link: StackBlitz 18.1.X
Steps to reproduce:
Actual Behavior
The number of calls to
getChildren
increases wildly, and I've also managed to un-deterministically enter a seemingly infinite loop.Environment
The text was updated successfully, but these errors were encountered: