From 412022899905db192262c9ac3a46266834fdba36 Mon Sep 17 00:00:00 2001 From: Sam Severance Date: Wed, 6 Mar 2019 03:40:12 -0500 Subject: [PATCH] refactor(selection-list): avoid deprecated method * use `FocusKeyManager`'s `updateActiveItem` method instead of deprecated `updateActiveItemIndex` * fix description of `MatSelectionList`'s `focus` method * remove `MatSelectionList`'s redundant `(focus)` event listener --- src/lib/list/selection-list.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/list/selection-list.ts b/src/lib/list/selection-list.ts index 359c935c6e9a..fc5d3ab97b91 100644 --- a/src/lib/list/selection-list.ts +++ b/src/lib/list/selection-list.ts @@ -300,7 +300,6 @@ export class MatListOption extends _MatListOptionMixinBase 'role': 'listbox', '[tabIndex]': 'tabIndex', 'class': 'mat-selection-list mat-list-base', - '(focus)': 'focus()', '(blur)': '_onTouched()', '(keydown)': '_keydown($event)', 'aria-multiselectable': 'true', @@ -416,7 +415,7 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu this._modelChanges.unsubscribe(); } - /** Focuses the last active list option. */ + /** Focuses the selection list. */ focus() { this._element.nativeElement.focus(); } @@ -446,9 +445,9 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu if (optionIndex > -1 && this._keyManager.activeItemIndex === optionIndex) { // Check whether the option is the last item if (optionIndex > 0) { - this._keyManager.updateActiveItemIndex(optionIndex - 1); + this._keyManager.updateActiveItem(optionIndex - 1); } else if (optionIndex === 0 && this.options.length > 1) { - this._keyManager.updateActiveItemIndex(Math.min(optionIndex + 1, this.options.length - 1)); + this._keyManager.updateActiveItem(Math.min(optionIndex + 1, this.options.length - 1)); } }