From 32641124740f81ab08f1bc69c62be92c719b8bd0 Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Wed, 20 Mar 2019 18:10:26 -0700 Subject: [PATCH] Fix focus when changing tab, blur previous tab. Fixes #95. Workaround for electron/electron#15718. --- app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 3bf38003..4de4b5a2 100644 --- a/app.js +++ b/app.js @@ -133,6 +133,8 @@ ipc.on('tabFocusNext', function() { var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); var i = activeIndex + 1; + tabPanel.getActiveTab().down('component').el.dom.blur(); + // "cycle" (go to the start) when the end is reached or the end is the spacer "tbfill" if (i === tabPanel.items.items.length || i === tabPanel.items.items.length - 1 && tabPanel.items.items[i].id === 'tbfill') i = 0; @@ -140,15 +142,18 @@ ipc.on('tabFocusNext', function() { while (tabPanel.items.items[i].id === 'tbfill') i++; tabPanel.setActiveTab(i); + tabPanel.getActiveTab().down('component').el.dom.focus(); }); ipc.on('tabFocusPrevious', function() { var tabPanel = Ext.cq1('app-main'); var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); var i = activeIndex - 1; + tabPanel.getActiveTab().down('component').el.dom.blur(); if ( i < 0 ) i = tabPanel.items.items.length - 1; while ( tabPanel.items.items[i].id === 'tbfill' || i < 0 ) i--; tabPanel.setActiveTab( i ); + tabPanel.getActiveTab().down('component').el.dom.focus(); }); ipc.on('tabZoomIn', function(key) { @@ -184,7 +189,10 @@ ipc.on('lockWindow', function(key) { }); ipc.on('goHome', function() { - Ext.cq1('app-main').setActiveTab(0); + const tabPanel = Ext.cq1('app-main'); + tabPanel.getActiveTab().down('component').el.dom.blur(); + tabPanel.setActiveTab(0); + tabPanel.getActiveTab().down('component').el.dom.focus(); }); // Focus the current service when Alt + Tab or click in webviews textfields