Skip to content

Commit 40a1331

Browse files
committed
feat(cdk/tree): implement aria-posinset and aria-setsize
1 parent 4918522 commit 40a1331

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
@@ -556,6 +556,7 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
556556
return this.treeControl?.getChildren ?? this.childrenAccessor;
557557
}
558558

559+
<<<<<<< HEAD
559560
/**
560561
* Gets the direct children of a node; used for compatibility between the old tree and the
561562
* new tree.
@@ -631,6 +632,16 @@ export class CdkTree<T, K = T> implements AfterContentChecked, CollectionViewer,
631632
return this._levels.get(node);
632633
}
633634

635+
_getPositionInSet(dataNode: T) {
636+
const group = this._getNodeGroup(dataNode);
637+
return group.indexOf(dataNode) + 1;
638+
}
639+
640+
_getSetSize(dataNode: T) {
641+
const group = this._getNodeGroup(dataNode);
642+
return group.length;
643+
}
644+
634645
private _getAllDescendants(): Observable<T[]> {
635646
return merge(...this._dataNodes.value.map(dataNode => this._getDescendants(dataNode)));
636647
}
@@ -833,11 +844,11 @@ export class CdkTreeNode<T, K = T> implements FocusableOption, OnDestroy, OnInit
833844
}
834845

835846
_getSetSize(): number {
836-
return 0;
847+
return this._tree._getSetSize(this._data);
837848
}
838849

839850
_getPositionInSet(): number {
840-
return 0;
851+
return this._tree._getPositionInSet(this._data);
841852
}
842853

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

0 commit comments

Comments
 (0)