Skip to content
Permalink
Browse files

fix(tab): Open new tab next to current tab

  • Loading branch information...
manavbp authored and joshuef committed Jul 2, 2019
1 parent 7fcb27f commit 3e9a9f7d16272e7ee87c821bdf55873d7b2799f0
Showing with 20 additions and 5 deletions.
  1. +18 −3 app/components/Browser/Browser.tsx
  2. +2 −2 app/components/Tab/Tab.tsx
@@ -307,11 +307,26 @@ class Browser extends Component<BrowserProps, {}> {
};

handleAddTabNext = ( tab ) => {
const { addTab, addTabEnd, setActiveTab, windowId } = this.props;
const { tabId, url, tabIndex } = tab;
const {
addTab,
addTabEnd,
setActiveTab,
windowId,
windows,
addTabNext
} = this.props;
const { activeTabId } = this.state;
const { tabId, url } = tab;
addTab( { tabId, url } );
const currentWindow = windows.openWindows[windowId]
? windows.openWindows[windowId]
: {};
const currentTabs = currentWindow !== {} ? currentWindow.tabs : [];
const tabIndex = currentTabs.findIndex(
( element ) => element === activeTabId
);
if ( tabIndex !== undefined ) {
addTabEnd( { tabId, tabIndex, windowId } );
addTabNext( { tabId, tabIndex, windowId } );
} else {
addTabEnd( { tabId, windowId } );
}
@@ -110,7 +110,7 @@ export class Tab extends Component<TabProps, TabState> {

buildMenu = ( webview ) => {
if ( !webview.getWebContents ) return; // 'not now, as you're running jest;
const { addTabEnd, windowId, toggleDevTools, tabId } = this.props;
const { windowId, toggleDevTools, tabId, addTabNext } = this.props;
// require here to avoid jest/electron remote issues
// eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
const contextMenu = require( 'electron-context-menu' );
@@ -171,7 +171,7 @@ export class Tab extends Component<TabProps, TabState> {
label: 'Open Link in New Tab',
visible: params.linkURL && params.linkURL.length > 0,
click() {
addTabEnd( {
addTabNext( {
url: params.linkURL,
windowId,
tabId: Math.random().toString( 36 )

0 comments on commit 3e9a9f7

Please sign in to comment.
You can’t perform that action at this time.