Skip to content

Commit

Permalink
Add an option to focus tab (instead of opening a new window) by click…
Browse files Browse the repository at this point in the history
…ing shift+enter from the search input

The first tab in the filtered tabs list will be focused.
  • Loading branch information
alongus committed Jul 7, 2017
1 parent cce3212 commit 72cab41
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/TabManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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"){
Expand Down

0 comments on commit 72cab41

Please sign in to comment.