Skip to content

Commit 4eea01a

Browse files
committed
fix(material/tree): add aria-expanded to ngOnInit
added aria-expanded to ngOnInit to get rid of ExpressionChangedAfterItHasBeenCheckedError Fixes #21922
1 parent bbcb8d0 commit 4eea01a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/cdk/tree/tree.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
321321
exportAs: 'cdkTreeNode',
322322
host: {
323323
'class': 'cdk-tree-node',
324-
'[attr.aria-expanded]': 'isExpanded',
324+
'[attr.aria-expanded]': 'isLeafNode ? null : isExpanded',
325325
},
326326
standalone: true,
327327
})
@@ -388,10 +388,7 @@ export class CdkTreeNode<T, K = T> implements FocusableOption, OnDestroy, OnInit
388388
return false;
389389
}
390390

391-
get isExpanded(): boolean | null {
392-
if (this.isLeafNode) {
393-
return null;
394-
}
391+
get isExpanded(): boolean {
395392
return this._tree.treeControl.isExpanded(this._data);
396393
}
397394

0 commit comments

Comments
 (0)