diff --git a/js/dom.js b/js/dom.js index 1034542b..495cff8f 100644 --- a/js/dom.js +++ b/js/dom.js @@ -329,6 +329,7 @@ function focusAccessibility() { if (focusables.includes(el.localName)) { if (el.dataset.focusedViaClick === undefined) { el.dataset.focusedViaClick = ''; + focusAccessibility.lastFocusedViaClick = true; } return; } @@ -337,6 +338,7 @@ function focusAccessibility() { function keepOutlineOnTab(event) { if (event.which === 9) { + focusAccessibility.lastFocusedViaClick = false; setTimeout(keepOutlineOnTab, 0, true); return; } else if (event !== true) { diff --git a/msgbox/msgbox.js b/msgbox/msgbox.js index 7a6ba81e..1a236c41 100644 --- a/msgbox/msgbox.js +++ b/msgbox/msgbox.js @@ -36,6 +36,10 @@ function messageBox({ messageBox.originalFocus = document.activeElement; moveFocus(messageBox.element, 1); + if (focusAccessibility.lastFocusedViaClick && document.activeElement) { + document.activeElement.dataset.focusedViaClick = ''; + } + if (typeof onshow === 'function') { onshow(messageBox.element); }