MessageBox: Add focus to OK button

This commit is contained in:
Rob Garrison 2017-12-22 22:18:40 -06:00 committed by tophf
parent f2efff64fd
commit 1fd0c26e1d

View File

@ -123,7 +123,7 @@ function messageBox({
function moveFocus(dir) {
const elements = [...messageBox.element.getElementsByTagName('*')];
const activeIndex = elements.indexOf(document.activeElement);
const activeIndex = Math.max(0, elements.indexOf(document.activeElement));
const num = elements.length;
for (let i = 1; i < num; i++) {
const elementIndex = (activeIndex + i * dir + num) % num;