From 2424f7a99597daf2c4730ce4b7a10ee89946cde3 Mon Sep 17 00:00:00 2001 From: akashnimare Date: Tue, 8 Aug 2017 22:13:03 +0530 Subject: [PATCH 1/2] Focus webview contents on Window focus #216 #251 --- app/renderer/js/components/webview.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/renderer/js/components/webview.js b/app/renderer/js/components/webview.js index 0c002d00..4256e92f 100644 --- a/app/renderer/js/components/webview.js +++ b/app/renderer/js/components/webview.js @@ -109,8 +109,10 @@ class WebView extends BaseComponent { // Explicit focusing the webview causes a bug the input cannot regain focus on Winodws. // The bug is introduced from Electron and this is a tempory fix. // See https://github.com/zulip/zulip-electron/issues/216 - // temporary fix - this.$el.focus(); + if (!this.$el.getWebContents().isFocused()) { + this.$el.focus(); + this.$el.getWebContents().focus(); + } } hide() { From 84a69ce45579a2ef4d850d02c1c0064a2f4203dd Mon Sep 17 00:00:00 2001 From: Zhongyi Tong Date: Wed, 9 Aug 2017 01:56:00 +0800 Subject: [PATCH 2/2] Enhance error handling. --- app/renderer/js/components/webview.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/renderer/js/components/webview.js b/app/renderer/js/components/webview.js index 4256e92f..6c497076 100644 --- a/app/renderer/js/components/webview.js +++ b/app/renderer/js/components/webview.js @@ -109,9 +109,10 @@ class WebView extends BaseComponent { // Explicit focusing the webview causes a bug the input cannot regain focus on Winodws. // The bug is introduced from Electron and this is a tempory fix. // See https://github.com/zulip/zulip-electron/issues/216 - if (!this.$el.getWebContents().isFocused()) { + const webContents = this.$el.getWebContents(); + if (webContents && !webContents.isFocused()) { this.$el.focus(); - this.$el.getWebContents().focus(); + webContents.focus(); } }