Skip to content

Commit b12a4f5

Browse files
committed
fix(cdk/tree): refactor rendering pipeline
This also refactors the parent/level/group data processing in order to make it significantly more consistent in all tree configurations.
1 parent c80cb86 commit b12a4f5

File tree

8 files changed

+237
-182
lines changed

8 files changed

+237
-182
lines changed

src/cdk/a11y/key-manager/tree-key-manager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,11 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
360360
}
361361

362362
private _updateActiveItemIndex(newItems: T[]) {
363-
if (this._activeItem) {
364-
const newIndex = newItems.indexOf(this._activeItem);
363+
const activeItem = this._activeItem;
364+
if (activeItem) {
365+
const newIndex = newItems.findIndex(
366+
item => this._trackByFn(item) === this._trackByFn(activeItem),
367+
);
365368

366369
if (newIndex > -1 && newIndex !== this._activeItemIndex) {
367370
this._activeItemIndex = newIndex;

src/cdk/tree/tree-errors.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,3 @@ export function getTreeControlMissingError() {
4646
export function getMultipleTreeControlsError() {
4747
return Error(`More than one of tree control, levelAccessor, or childrenAccessor were provided.`);
4848
}
49-
50-
/**
51-
* Returns an error to be thrown when a node is attempted to be expanded or collapsed when
52-
* it's not expandable.
53-
* @docs-private
54-
*/
55-
export function getNodeNotExpandableError() {
56-
return Error(
57-
`The node that was attempted to be expanded or collapsed is not expandable; you might ` +
58-
`need to provide 'isExpandable'.`,
59-
);
60-
}

0 commit comments

Comments
 (0)