From 527c5fb43ee5d2b6b07ab051fc503b51127ae8ff Mon Sep 17 00:00:00 2001 From: dkanada Date: Sun, 15 Mar 2020 18:47:06 +0900 Subject: [PATCH] Merge pull request #920 from dmitrylyzo/fix_slideshow-2 Fix slideshow 2 (cherry picked from commit 95f379021e9762d54c3f0b50a5367620f3a42d40) Signed-off-by: Joshua M. Boniface --- src/components/dialogHelper/dialogHelper.js | 6 ++++++ src/scripts/inputManager.js | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js index 6ee96df318..d8ddc13c0a 100644 --- a/src/components/dialogHelper/dialogHelper.js +++ b/src/components/dialogHelper/dialogHelper.js @@ -242,9 +242,15 @@ define(['appRouter', 'focusManager', 'browser', 'layoutManager', 'inputManager', var onAnimationFinish = function () { focusManager.pushScope(dlg); + if (dlg.getAttribute('data-autofocus') === 'true') { focusManager.autoFocus(dlg); } + + if (document.activeElement && !dlg.contains(document.activeElement)) { + // Blur foreign element to prevent triggering of an action from the previous scope + document.activeElement.blur(); + } }; if (enableAnimation()) { diff --git a/src/scripts/inputManager.js b/src/scripts/inputManager.js index 2db8aaa56a..4d62ff9f20 100644 --- a/src/scripts/inputManager.js +++ b/src/scripts/inputManager.js @@ -58,7 +58,15 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom', 'apphost'], funct sourceElement = focusManager.focusableParent(sourceElement); } - sourceElement = sourceElement || document.activeElement || window; + if (!sourceElement) { + sourceElement = document.activeElement || window; + + var dlg = document.querySelector('.dialogContainer .dialog.opened'); + + if (dlg && (!sourceElement || !dlg.contains(sourceElement))) { + sourceElement = dlg; + } + } if (eventListenerCount) { var customEvent = new CustomEvent("command", {