From 92ac2f8095eefbcd61ca1322b6fd8ec95f8b304e Mon Sep 17 00:00:00 2001 From: Alon Lavi Date: Fri, 7 Jul 2017 13:27:50 +0300 Subject: [PATCH] Add an option to focus tab (instead of opening a new window) by clicking shift+enter from the search input The first tab in the filtered tabs list will be focused. --- lib/TabManager.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/TabManager.js b/lib/TabManager.js index 0b45711..e9305b6 100644 --- a/lib/TabManager.js +++ b/lib/TabManager.js @@ -95,6 +95,15 @@ var TabManager = React.createFactory(React.createClass({ deleteTab:function(tabId) { chrome.tabs.remove(tabId); }, + focusTab:function(){ + var tabs = Object.keys(this.state.selection).map(id => this.state.tabsbyid[id]); + var first = tabs.shift(); + if(first){ + chrome.tabs.update(first.id, {active: true}, function(tab) { + chrome.windows.update(tab.windowId, {focused: true}); + }); + } + }, addWindow:function(){ var tabs = Object.keys(this.state.selection).map(id => this.state.tabsbyid[id]); var first = tabs.shift(); @@ -167,7 +176,13 @@ var TabManager = React.createFactory(React.createClass({ this.forceUpdate(); }, checkEnter:function(e){ - if(e.keyCode == 13) this.addWindow(); + if(e.keyCode == 13) { + if(e.nativeEvent.shiftKey){ + this.focusTab(); + }else{ + this.addWindow(); + } + } }, changelayout:function(){ if(this.state.layout == "blocks"){