From f9ec9e3b52143a669d4c3eebadaff771d5bd51ac Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Tue, 10 Mar 2020 18:19:18 +0300 Subject: [PATCH 1/5] Add opened dialog as inputManager event source --- src/scripts/inputManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scripts/inputManager.js b/src/scripts/inputManager.js index 2db8aaa56a..772f13b8c7 100644 --- a/src/scripts/inputManager.js +++ b/src/scripts/inputManager.js @@ -58,7 +58,7 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom', 'apphost'], funct sourceElement = focusManager.focusableParent(sourceElement); } - sourceElement = sourceElement || document.activeElement || window; + sourceElement = sourceElement || document.querySelector('.dialogContainer .dialog.opened') || document.activeElement || window; if (eventListenerCount) { var customEvent = new CustomEvent("command", { From 485ccfa11690ced4593dca1fbd853722ff4e6647 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Tue, 10 Mar 2020 18:50:31 +0300 Subject: [PATCH 2/5] Prevent nested slideshow --- src/components/slideshow/slideshow.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/slideshow/slideshow.js b/src/components/slideshow/slideshow.js index 40d87e9519..67cae4b6b0 100644 --- a/src/components/slideshow/slideshow.js +++ b/src/components/slideshow/slideshow.js @@ -188,6 +188,11 @@ define(['dialogHelper', 'inputManager', 'connectionManager', 'layoutManager', 'f stopInterval(); }); + // Blur foreign element to prevent starting of "nested" slideshow + if (document.activeElement && !dlg.contains(document.activeElement)) { + document.activeElement.blur(); + } + inputManager.on(window, onInputCommand); document.addEventListener((window.PointerEvent ? 'pointermove' : 'mousemove'), onPointerMove); From 305f050003458f7f84e5be8414cd0a62c899d2ef Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 14 Mar 2020 22:26:08 +0300 Subject: [PATCH 3/5] Move blur of foreign element to generic dialog module --- src/components/dialogHelper/dialogHelper.js | 3 +++ src/components/slideshow/slideshow.js | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js index 6ee96df318..b9bc71bc1d 100644 --- a/src/components/dialogHelper/dialogHelper.js +++ b/src/components/dialogHelper/dialogHelper.js @@ -244,6 +244,9 @@ define(['appRouter', 'focusManager', 'browser', 'layoutManager', 'inputManager', focusManager.pushScope(dlg); if (dlg.getAttribute('data-autofocus') === 'true') { focusManager.autoFocus(dlg); + } else if (document.activeElement && !dlg.contains(document.activeElement)) { + // Blur foreign element to prevent triggering of an action from the previous scope + document.activeElement.blur(); } }; diff --git a/src/components/slideshow/slideshow.js b/src/components/slideshow/slideshow.js index 67cae4b6b0..40d87e9519 100644 --- a/src/components/slideshow/slideshow.js +++ b/src/components/slideshow/slideshow.js @@ -188,11 +188,6 @@ define(['dialogHelper', 'inputManager', 'connectionManager', 'layoutManager', 'f stopInterval(); }); - // Blur foreign element to prevent starting of "nested" slideshow - if (document.activeElement && !dlg.contains(document.activeElement)) { - document.activeElement.blur(); - } - inputManager.on(window, onInputCommand); document.addEventListener((window.PointerEvent ? 'pointermove' : 'mousemove'), onPointerMove); From 4d6f187aee013a377e79754ef8f32cdb71558cb5 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sat, 14 Mar 2020 22:29:58 +0300 Subject: [PATCH 4/5] Fix event source for inputManager --- src/scripts/inputManager.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/scripts/inputManager.js b/src/scripts/inputManager.js index 772f13b8c7..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.querySelector('.dialogContainer .dialog.opened') || 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", { From 53d2e8c0d29eec892193b6ff8bcd5d31d7adb6dd Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Sun, 15 Mar 2020 02:18:27 +0300 Subject: [PATCH 5/5] Always try to blur foreign element --- src/components/dialogHelper/dialogHelper.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/dialogHelper/dialogHelper.js b/src/components/dialogHelper/dialogHelper.js index b9bc71bc1d..d8ddc13c0a 100644 --- a/src/components/dialogHelper/dialogHelper.js +++ b/src/components/dialogHelper/dialogHelper.js @@ -242,9 +242,12 @@ define(['appRouter', 'focusManager', 'browser', 'layoutManager', 'inputManager', var onAnimationFinish = function () { focusManager.pushScope(dlg); + if (dlg.getAttribute('data-autofocus') === 'true') { focusManager.autoFocus(dlg); - } else if (document.activeElement && !dlg.contains(document.activeElement)) { + } + + if (document.activeElement && !dlg.contains(document.activeElement)) { // Blur foreign element to prevent triggering of an action from the previous scope document.activeElement.blur(); }