Skip to content

Commit ee76278

Browse files
committed
feat(cdk/tree): implement aria-posinset and aria-setsize
1 parent ac644af commit ee76278

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/cdk/tree/tree.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
553553
return this.treeControl?.getChildren ?? this.childrenAccessor;
554554
}
555555

556+
<<<<<<< HEAD
556557
/**
557558
* Gets the direct children of a node; used for compatibility between the old tree and the
558559
* new tree.
@@ -628,6 +629,16 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
628629
return this._levels.get(node);
629630
}
630631

632+
_getPositionInSet(dataNode: T) {
633+
const group = this._getNodeGroup(dataNode);
634+
return group.indexOf(dataNode) + 1;
635+
}
636+
637+
_getSetSize(dataNode: T) {
638+
const group = this._getNodeGroup(dataNode);
639+
return group.length;
640+
}
641+
631642
private _getAllDescendants(): Observable<T[]> {
632643
return merge(...this._dataNodes.value.map(dataNode => this._getDescendants(dataNode)));
633644
}
@@ -878,11 +889,11 @@ export class CdkTreeNode<T, K = T> implements FocusableOption, OnDestroy, OnInit
878889
}
879890

880891
_getSetSize(): number {
881-
return 0;
892+
return this._tree._getSetSize(this._data);
882893
}
883894

884895
_getPositionInSet(): number {
885-
return 0;
896+
return this._tree._getPositionInSet(this._data);
886897
}
887898

888899
constructor(protected _elementRef: ElementRef<HTMLElement>, protected _tree: CdkTree<T, K>) {

0 commit comments

Comments
 (0)