Skip to content

Commit 32c9696

Browse files
committed
feat(cdk/tree): implement aria-posinset and aria-setsize
1 parent 50a6100 commit 32c9696

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
@@ -631,6 +631,16 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
631631
return this._levels.get(node);
632632
}
633633

634+
_getPositionInSet(dataNode: T) {
635+
const group = this._getNodeGroup(dataNode);
636+
return group.indexOf(dataNode) + 1;
637+
}
638+
639+
_getSetSize(dataNode: T) {
640+
const group = this._getNodeGroup(dataNode);
641+
return group.length;
642+
}
643+
634644
/**
635645
* Gets all nodes in the tree, through recursive expansion.
636646
*
@@ -844,11 +854,11 @@ export class CdkTreeNode<T, K = T> implements FocusableOption, OnDestroy, OnInit
844854
}
845855

846856
_getSetSize(): number {
847-
return 0;
857+
return this._tree._getSetSize(this._data);
848858
}
849859

850860
_getPositionInSet(): number {
851-
return 0;
861+
return this._tree._getPositionInSet(this._data);
852862
}
853863

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

0 commit comments

Comments
 (0)