Open examan opened 3 months ago
Shouldn't the cdk-tree-node
have [isExpanded]="true"
in order to have everything expended by default?
It doesn't change the fact that there's an issue of course, but to get your workaround working I had to add that
Ok I finally got the mat tree working as expected in my app. There's definitely a bug as pointed out by @examan and BTW thanks a lot for providing a workaround, saved me a ton of time :pray:!
I took a quick look at this; I suspect the issue ultimately comes from the fact that we're only getting isExpanded
information when the node is rendered. This causes the _renderDataChanges
call to trigger expansion model changes, which then aren't picked up by the rendering pipeline as that subscription only registers after the first complete run of the subscribed function. I'm not currently sure what a good fix for it is, but it does mean that this all has to be computed in multiple stages.
Is this a regression?
The previous version in which this bug was not present was
No response
Description
Using cdk-tree with ArrayDataSource and synchronous data, the isExpanded functionality can fail.
Reproduction
StackBlitz link: https://stackblitz.com/edit/2ypkpy-yxnpzh?file=src%2Fexample%2Fcdk-tree-flat-children-accessor-example.ts Steps to reproduce: load the page
Expected Behavior
All nodes automatically expand.
Actual Behavior
Some nodes did not automatically expand.
Environment