Skip to content

Commit 0ad416a

Browse files
committed
feat(cdk/tree): implement aria-posinset and aria-setsize
1 parent 1303386 commit 0ad416a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/cdk/tree/tree.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,16 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
620620
return this._levels.get(node);
621621
}
622622

623+
_getPositionInSet(dataNode: T) {
624+
const group = this._getNodeGroup(dataNode);
625+
return group.indexOf(dataNode) + 1;
626+
}
627+
628+
_getSetSize(dataNode: T) {
629+
const group = this._getNodeGroup(dataNode);
630+
return group.length;
631+
}
632+
623633
/**
624634
* Gets all nodes in the tree, through recursive expansion.
625635
*
@@ -850,11 +860,11 @@ export class CdkTreeNode<T, K = T> implements FocusableOption, OnDestroy, OnInit
850860
}
851861

852862
_getSetSize(): number {
853-
return 0;
863+
return this._tree._getSetSize(this._data);
854864
}
855865

856866
_getPositionInSet(): number {
857-
return 0;
867+
return this._tree._getPositionInSet(this._data);
858868
}
859869

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

0 commit comments

Comments
 (0)