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", {