Bug 1573159 - Only call scrollIntoView() on login-list item if it isn't in view. r=MattN

Differential Revision: https://phabricator.services.mozilla.com/D41886

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tim Nguyen 2019-08-15 21:27:42 +00:00
Родитель 0a772dbcbb
Коммит d0b9568ea8
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -473,7 +473,7 @@ export default class LoginList extends HTMLElement {
this._list.setAttribute("aria-activedescendant", newlyFocusedItem.id);
activeDescendant.classList.remove("keyboard-selected");
newlyFocusedItem.classList.add("keyboard-selected");
newlyFocusedItem.scrollIntoView(false);
newlyFocusedItem.scrollIntoView({ block: "nearest" });
}
_setListItemAsSelected(listItem) {
@ -486,9 +486,11 @@ export default class LoginList extends HTMLElement {
this._createLoginButton.disabled = !listItem.dataset.guid;
listItem.classList.add("selected");
listItem.setAttribute("aria-selected", "true");
listItem.scrollIntoView();
this._list.setAttribute("aria-activedescendant", listItem.id);
this._selectedGuid = listItem.dataset.guid;
// Scroll item into view if it isn't visible
listItem.scrollIntoView({ block: "nearest" });
}
}
customElements.define("login-list", LoginList);