From 1fd0c26e1dcfe23faa40aad4c1ae6b30f46a812b Mon Sep 17 00:00:00 2001 From: Rob Garrison Date: Fri, 22 Dec 2017 22:18:40 -0600 Subject: [PATCH] MessageBox: Add focus to OK button --- msgbox/msgbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msgbox/msgbox.js b/msgbox/msgbox.js index a9470c46..3f40fdaa 100644 --- a/msgbox/msgbox.js +++ b/msgbox/msgbox.js @@ -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;