aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vimiumFrontend.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 594438e9..736f14b0 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -158,7 +158,7 @@ function initializeWhenEnabled() {
document.addEventListener("keypress", onKeypress, true);
document.addEventListener("keyup", onKeyup, true);
document.addEventListener("focus", onFocusCapturePhase, true);
- document.addEventListener("blur", onBlurCapturePhase, true);
+ window.addEventListener("blur", onBlurCapturePhase, true);
enterInsertModeIfElementIsFocused();
}
@@ -479,7 +479,12 @@ function onFocusCapturePhase(event) {
}
function onBlurCapturePhase(event) {
- if (isFocusable(event.target))
+ if (event.target == window)
+ // At this point, we will have exited insert mode already, but the browser remembers which element last
+ // had focus, and fires a focus event on it when the window regains focus. We blur this element to prevent
+ // implicit insert mode from reactivating when we switch back to this tab.
+ document.activeElement.blur();
+ else if (isFocusable(event.target))
exitInsertMode(event.target);
}