Skip to content

Commit bbfea90

Browse files
committed
feat(cdk/a11y): use skipPredicate instead of disabled
1 parent 8b4251c commit bbfea90

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
116116
* Predicate function that can be used to check whether an item should be skipped
117117
* by the key manager. By default, disabled items are skipped.
118118
*/
119-
private _skipPredicateFn = (item: T) =>
120-
typeof item.isDisabled === 'boolean' ? item.isDisabled : !!item.isDisabled?.();
119+
private _skipPredicateFn = (item: T) => this._isItemDisabled(item);
121120

122121
/** Function to determine equivalent items. */
123122
private _trackByFn: (item: T) => unknown = (item: T) => item;
@@ -337,7 +336,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
337336
this._activeItem.collapse();
338337
} else {
339338
const parent = this._activeItem.getParent();
340-
if (!parent || this._isItemDisabled(parent)) {
339+
if (!parent || this._skipPredicateFn(parent as T)) {
341340
return;
342341
}
343342
this._setActiveItem(parent as T);
@@ -358,7 +357,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
358357
coerceObservable(this._activeItem.getChildren())
359358
.pipe(take(1))
360359
.subscribe(children => {
361-
const firstChild = children.find(child => !this._isItemDisabled(child));
360+
const firstChild = children.find(child => !this._skipPredicateFn(child as T));
362361
if (!firstChild) {
363362
return;
364363
}

0 commit comments

Comments
 (0)