Skip to content

Commit 4895443

Browse files
swseverancemmalerba
authored andcommitted
refactor(selection-list): avoid deprecated method (#15393)
* use `FocusKeyManager`'s `updateActiveItem` method instead of deprecated `updateActiveItemIndex` * fix description of `MatSelectionList`'s `focus` method * remove `MatSelectionList`'s redundant `(focus)` event listener
1 parent c2f3d48 commit 4895443

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/lib/list/selection-list.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ export class MatListOption extends _MatListOptionMixinBase
300300
'role': 'listbox',
301301
'[tabIndex]': 'tabIndex',
302302
'class': 'mat-selection-list mat-list-base',
303-
'(focus)': 'focus()',
304303
'(blur)': '_onTouched()',
305304
'(keydown)': '_keydown($event)',
306305
'aria-multiselectable': 'true',
@@ -416,7 +415,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
416415
this._modelChanges.unsubscribe();
417416
}
418417

419-
/** Focuses the last active list option. */
418+
/** Focuses the selection list. */
420419
focus() {
421420
this._element.nativeElement.focus();
422421
}
@@ -446,9 +445,9 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
446445
if (optionIndex > -1 && this._keyManager.activeItemIndex === optionIndex) {
447446
// Check whether the option is the last item
448447
if (optionIndex > 0) {
449-
this._keyManager.updateActiveItemIndex(optionIndex - 1);
448+
this._keyManager.updateActiveItem(optionIndex - 1);
450449
} else if (optionIndex === 0 && this.options.length > 1) {
451-
this._keyManager.updateActiveItemIndex(Math.min(optionIndex + 1, this.options.length - 1));
450+
this._keyManager.updateActiveItem(Math.min(optionIndex + 1, this.options.length - 1));
452451
}
453452
}
454453

0 commit comments

Comments
 (0)