@@ -120,8 +120,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
120
120
* Predicate function that can be used to check whether an item should be skipped
121
121
* by the key manager. By default, disabled items are skipped.
122
122
*/
123
- private _skipPredicateFn = ( item : T ) =>
124
- typeof item . isDisabled === 'boolean' ? item . isDisabled : ! ! item . isDisabled ?.( ) ;
123
+ private _skipPredicateFn = ( item : T ) => this . _isItemDisabled ( item ) ;
125
124
126
125
/** Function to determine equivalent items. */
127
126
private _trackByFn : ( item : T ) => unknown = ( item : T ) => item ;
@@ -313,7 +312,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
313
312
314
313
private _findNextAvailableItemIndex ( startingIndex : number ) {
315
314
for ( let i = startingIndex + 1 ; i < this . _items . length ; i ++ ) {
316
- if ( ! this . _isItemDisabled ( this . _items [ i ] ) ) {
315
+ if ( ! this . _skipPredicateFn ( this . _items [ i ] ) ) {
317
316
return i ;
318
317
}
319
318
}
@@ -322,7 +321,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
322
321
323
322
private _findPreviousAvailableItemIndex ( startingIndex : number ) {
324
323
for ( let i = startingIndex - 1 ; i >= 0 ; i -- ) {
325
- if ( ! this . _isItemDisabled ( this . _items [ i ] ) ) {
324
+ if ( ! this . _skipPredicateFn ( this . _items [ i ] ) ) {
326
325
return i ;
327
326
}
328
327
}
@@ -341,7 +340,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
341
340
this . _activeItem . collapse ( ) ;
342
341
} else {
343
342
const parent = this . _activeItem . getParent ( ) ;
344
- if ( ! parent || this . _isItemDisabled ( parent ) ) {
343
+ if ( ! parent || this . _skipPredicateFn ( parent as T ) ) {
345
344
return ;
346
345
}
347
346
this . _setActiveItem ( parent as T ) ;
@@ -362,7 +361,7 @@ export class TreeKeyManager<T extends TreeKeyManagerItem> {
362
361
coerceObservable ( this . _activeItem . getChildren ( ) )
363
362
. pipe ( take ( 1 ) )
364
363
. subscribe ( children => {
365
- const firstChild = children . find ( child => ! this . _isItemDisabled ( child ) ) ;
364
+ const firstChild = children . find ( child => ! this . _skipPredicateFn ( child as T ) ) ;
366
365
if ( ! firstChild ) {
367
366
return ;
368
367
}
0 commit comments