Skip to content

Commit 2ed316d

Browse files
committed
fix(cdk/tree): fix flat tree demo
1 parent 88335dc commit 2ed316d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/cdk/tree/tree.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,6 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
185185
/** Maintain a synchronous cache of the currently known data nodes. */
186186
private _dataNodes: BehaviorSubject<readonly T[]> = new BehaviorSubject<readonly T[]>([]);
187187

188-
/** Maintain a synchronous cache of the currently rendered nodes. */
189-
private _renderedNodes: BehaviorSubject<Set<T>> = new BehaviorSubject<Set<T>>(new Set());
190-
191188
/** The mapping between data and the node that is rendered. */
192189
private _nodes: BehaviorSubject<Map<K, CdkTreeNode<T, K>>> = new BehaviorSubject(
193190
new Map<K, CdkTreeNode<T, K>>(),

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {ArrayDataSource} from '@angular/cdk/collections';
2-
import {Component} from '@angular/core';
2+
import {CdkTree} from '@angular/cdk/tree';
3+
import {Component, ViewChild} from '@angular/core';
34
import {FlatFoodNode, FLAT_DATA} from '../tree-data';
45

56
/**
@@ -11,6 +12,9 @@ import {FlatFoodNode, FLAT_DATA} from '../tree-data';
1112
styleUrls: ['cdk-tree-flat-level-accessor-example.css'],
1213
})
1314
export class CdkTreeFlatLevelAccessorExample {
15+
@ViewChild(CdkTree)
16+
tree: CdkTree<FlatFoodNode>;
17+
1418
levelAccessor = (dataNode: FlatFoodNode) => dataNode.level;
1519

1620
dataSource = new ArrayDataSource(FLAT_DATA);
@@ -32,7 +36,7 @@ export class CdkTreeFlatLevelAccessorExample {
3236
shouldRender(node: FlatFoodNode) {
3337
let parent = this.getParentNode(node);
3438
while (parent) {
35-
if (!parent.isExpanded) {
39+
if (!this.tree?.isExpanded(parent)) {
3640
return false;
3741
}
3842
parent = this.getParentNode(parent);

0 commit comments

Comments
 (0)