diff --git a/js/dlg/message-box.js b/js/dlg/message-box.js index 31de0726..423c39a3 100644 --- a/js/dlg/message-box.js +++ b/js/dlg/message-box.js @@ -53,6 +53,9 @@ messageBox.show = async ({ if (focusAccessibility.lastFocusedViaClick && document.activeElement) { document.activeElement.dataset.focusedViaClick = ''; } + if (document.activeElement === messageBox._originalFocus) { + document.body.focus(); + } if (typeof onshow === 'function') { onshow(messageBox.element); diff --git a/js/dom.js b/js/dom.js index b10272f5..a308498c 100644 --- a/js/dom.js +++ b/js/dom.js @@ -260,7 +260,7 @@ function moveFocus(rootElement, step) { const activeIndex = step ? Math.max(step < 0 ? 0 : -1, elements.indexOf(activeEl)) : -1; const num = elements.length; if (!step) step = 1; - for (let i = 1; i < num; i++) { + for (let i = 1; i <= num; i++) { const el = elements[(activeIndex + i * step + num) % num]; if (!el.disabled && el.tabIndex >= 0) { el.focus();