From 72cab4114249723f486ea758108ebe8381c8ffc9 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/TabManager.js b/lib/TabManager.js index 0b45711..d0f5f63 100644 --- a/lib/TabManager.js +++ b/lib/TabManager.js @@ -95,6 +95,13 @@ 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,{selected:true}); + } + }, addWindow:function(){ var tabs = Object.keys(this.state.selection).map(id => this.state.tabsbyid[id]); var first = tabs.shift(); @@ -167,7 +174,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"){