Skip to content

Commit dee7d14

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 f4b5d43 commit dee7d14

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
@@ -288,7 +288,6 @@ export class MatListOption extends _MatListOptionMixinBase
288288
'role': 'listbox',
289289
'[tabIndex]': 'tabIndex',
290290
'class': 'mat-selection-list mat-list-base',
291-
'(focus)': 'focus()',
292291
'(blur)': '_onTouched()',
293292
'(keydown)': '_keydown($event)',
294293
'aria-multiselectable': 'true',
@@ -399,7 +398,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
399398
this._modelChanges.unsubscribe();
400399
}
401400

402-
/** Focuses the last active list option. */
401+
/** Focuses the selection list. */
403402
focus() {
404403
this._element.nativeElement.focus();
405404
}
@@ -429,9 +428,9 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu
429428
if (optionIndex > -1 && this._keyManager.activeItemIndex === optionIndex) {
430429
// Check whether the option is the last item
431430
if (optionIndex > 0) {
432-
this._keyManager.updateActiveItemIndex(optionIndex - 1);
431+
this._keyManager.updateActiveItem(optionIndex - 1);
433432
} else if (optionIndex === 0 && this.options.length > 1) {
434-
this._keyManager.updateActiveItemIndex(Math.min(optionIndex + 1, this.options.length - 1));
433+
this._keyManager.updateActiveItem(Math.min(optionIndex + 1, this.options.length - 1));
435434
}
436435
}
437436

0 commit comments

Comments
 (0)