Skip to content

Commit 284a8fe

Browse files
Victoria WeiVictoria Wei
authored andcommitted
fixed mat-tree not closing children in tree-dynamic-example file as well
1 parent 53830b0 commit 284a8fe

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/material-examples/tree-dynamic/tree-dynamic-example.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,22 @@ export class DynamicDataSource {
9494

9595
node.isLoading = true;
9696

97+
let count = 0;
98+
9799
setTimeout(() => {
98100
if (expand) {
99101
const nodes = children.map(name =>
100102
new DynamicFlatNode(name, node.level + 1, this.database.isExpandable(name)));
101103
this.data.splice(index + 1, 0, ...nodes);
102104
} else {
103-
this.data.splice(index + 1, children.length);
105+
for (let i = index + 1; i < this.data.length; i++) {
106+
if (this.data[i].level > node.level) {
107+
count++;
108+
} else {
109+
break;
110+
}
111+
}
112+
this.data.splice(index + 1, count);
104113
}
105114

106115
// notify the change

0 commit comments

Comments
 (0)