From c57fef7b1e616a077c82cde883a3ade188a8ac16 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 6 Sep 2018 19:05:10 +0300 Subject: [PATCH] suppress focus outline when invoked via mouse fixes #495 --- js/dom.js | 2 ++ msgbox/msgbox.js | 4 ++++ 2 files changed, 6 insertions(+) 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); }