From e898b6bea5581af4e4cf0f31e6bcfff029c88b47 Mon Sep 17 00:00:00 2001 From: Richard Maisano Date: Thu, 30 Apr 2015 16:30:21 -0400 Subject: [PATCH] Check if modalElement exists in handleFocus. A race condition happens if you open a new window before closing the modal, as opening a new window has the side effect of blurring the current window. --- lib/helpers/focusManager.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/helpers/focusManager.js b/lib/helpers/focusManager.js index 38b854a2..953b66cb 100644 --- a/lib/helpers/focusManager.js +++ b/lib/helpers/focusManager.js @@ -10,6 +10,9 @@ function handleBlur(event) { function handleFocus(event) { if (needToFocus) { needToFocus = false; + if (!modalElement) { + return; + } // need to see how jQuery shims document.on('focusin') so we don't need the // setTimeout, firefox doesn't support focusin, if it did, we could focus // the the element outisde of a setTimeout. Side-effect of this