From f4b81eff3054e4277e97d06290535bfecc9b9cc1 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sun, 1 Sep 2019 22:34:37 +0300 Subject: [PATCH] fix parent focus issues for Firefox and Chrome --- ext/fg/js/popup.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index 3bc0b6f8..df7dc6b5 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -239,9 +239,15 @@ class Popup { } focusParent() { - this.container.blur(); if (this.parent && this.parent.container) { - this.parent.container.focus(); + // Chrome doesn't like focusing iframe without contentWindow. + this.parent.container.contentWindow.focus(); + } else { + // Firefox doesn't like focusing window without first blurring the iframe. + // this.container.contentWindow.blur() doesn't work on Firefox for some reason. + this.container.blur(); + // This is needed for Chrome. + window.focus(); } }