Skip to content

Commit 0383071

Browse files
bochalitommalerba
authored andcommitted
docs(cdk/tree): collapse child nodes if top level collapses (#20683)
Fixes a bug in the Angular CDK Tree examples where the children nodes are still visible when the top level node is collapsed. This is because the `shouldRender()` method of the `cdk-flat-tree-example.ts` is checking only the parent of current node. Fixes #20665 (cherry picked from commit a90a072)
1 parent 3393ec7 commit 0383071

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components-examples/cdk/tree/cdk-tree-flat/cdk-tree-flat-example.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ export class CdkTreeFlatExample {
8888
}
8989

9090
shouldRender(node: ExampleFlatNode) {
91-
const parent = this.getParentNode(node);
92-
return !parent || parent.isExpanded;
91+
let parent = this.getParentNode(node);
92+
while (parent) {
93+
if (!parent.isExpanded) {
94+
return false;
95+
}
96+
parent = this.getParentNode(parent);
97+
}
98+
return true;
9399
}
94100
}

0 commit comments

Comments
 (0)