From ddeb75c3dad54c53973911e4778741e6c0200028 Mon Sep 17 00:00:00 2001 From: Gyandeep Singh Date: Tue, 20 Dec 2016 11:12:20 -0600 Subject: [PATCH] Update: Keep tabs same size when closing (fixes #6088) Same behavior as chrome --- js/actions/windowActions.js | 14 ++++++++++++++ js/components/main.js | 1 + js/components/tab.js | 4 +++- js/components/tabs.js | 19 ++++++++++++++++++- js/components/tabsToolbar.js | 1 + js/constants/windowConstants.js | 4 +++- js/stores/windowStore.js | 8 ++++++++ 7 files changed, 48 insertions(+), 3 deletions(-) diff --git a/js/actions/windowActions.js b/js/actions/windowActions.js index 2878948a432..797f72c0357 100644 --- a/js/actions/windowActions.js +++ b/js/actions/windowActions.js @@ -1198,6 +1198,20 @@ const windowActions = { tabId, notify }) + }, + + onTabClose: function (data) { + dispatch({ + actionType: windowConstants.WINDOW_TAB_CLOSE, + data + }) + }, + + onTabMouseLeave: function (data) { + dispatch({ + actionType: windowConstants.WINDOW_TAB_MOUSE_LEAVE, + data + }) } } diff --git a/js/components/main.js b/js/components/main.js index 9bcf83ec46b..35f1cc1b571 100644 --- a/js/components/main.js +++ b/js/components/main.js @@ -1180,6 +1180,7 @@ class Main extends ImmutableComponent { tabsPerTabPage={tabsPerPage} tabPageIndex={this.props.windowState.getIn(['ui', 'tabs', 'tabPageIndex'])} previewTabPageIndex={this.props.windowState.getIn(['ui', 'tabs', 'previewTabPageIndex'])} + fixTabWidth={this.props.windowState.getIn(['ui', 'tabs', 'fixTabWidth'])} tabs={this.props.windowState.get('tabs')} sites={appStateSites} key='tab-bar' diff --git a/js/components/tab.js b/js/components/tab.js index 20ef799e872..21e04505349 100644 --- a/js/components/tab.js +++ b/js/components/tab.js @@ -105,6 +105,7 @@ class Tab extends ImmutableComponent { onCloseFrame (event) { event.stopPropagation() + this.props.onFrameClose(this.tabNode.parentNode.getBoundingClientRect()) windowActions.closeFrame(windowStore.getFrames(), this.frame) } @@ -196,8 +197,9 @@ class Tab extends ImmutableComponent { draggingOverRight: this.isDraggingOverRight, isDragging: this.isDragging, isPinned: this.isPinned, - partOfFullPageSet: this.props.partOfFullPageSet + partOfFullPageSet: this.props.partOfFullPageSet || !!this.props.tabWidth })} + style={this.props.tabWidth ? { flex: `0 0 ${this.props.tabWidth}px` } : {}} onMouseEnter={this.props.previewTabs ? this.onMouseEnter : null} onMouseLeave={this.props.previewTabs ? this.onMouseLeave : null}>
+ return
) } {(() => { diff --git a/js/components/tabsToolbar.js b/js/components/tabsToolbar.js index ea42d611981..d6723051625 100644 --- a/js/components/tabsToolbar.js +++ b/js/components/tabsToolbar.js @@ -69,6 +69,7 @@ class TabsToolbar extends ImmutableComponent { previewTabPageIndex={this.props.previewTabPageIndex} startingFrameIndex={startingFrameIndex} partOfFullPageSet={currentTabs.size === this.props.tabsPerTabPage} + fixTabWidth={this.props.fixTabWidth} /> { case appConstants.APP_NEW_TAB: newFrame(action.frameProps, action.frameProps.get('disposition') === 'foreground-tab') break + case windowConstants.WINDOW_TAB_CLOSE: + windowState = windowState.setIn(['ui', 'tabs', 'fixTabWidth'], action.data.fixTabWidth) + windowStore.emitChanges() + break + case windowConstants.WINDOW_TAB_MOUSE_LEAVE: + windowState = windowState.setIn(['ui', 'tabs', 'fixTabWidth'], action.data.fixTabWidth) + windowStore.emitChanges() + break default: break }