Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Update: Keep tabs same size when closing (fixes #6088)
Browse files Browse the repository at this point in the history
Same behavior as chrome
  • Loading branch information
gyandeeps authored and bsclifton committed Jan 26, 2017
1 parent b459adf commit ddeb75c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 3 deletions.
14 changes: 14 additions & 0 deletions js/actions/windowActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}
}

Expand Down
1 change: 1 addition & 0 deletions js/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 3 additions & 1 deletion js/components/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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}>
<div className={cx({
Expand Down
19 changes: 18 additions & 1 deletion js/components/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ class Tabs extends ImmutableComponent {
this.onNextPage = this.onNextPage.bind(this)
this.onNewTabLongPress = this.onNewTabLongPress.bind(this)
this.wasNewTabClicked = this.wasNewTabClicked.bind(this)
this.onMouseLeave = this.onMouseLeave.bind(this)
this.onFrameClose = this.onFrameClose.bind(this)
}

onMouseLeave () {
windowActions.onTabMouseLeave({
fixTabWidth: null
})
}

onFrameClose (rect) {
windowActions.onTabClose({
fixTabWidth: rect.width
})
}

onPrevPage () {
Expand Down Expand Up @@ -100,7 +114,8 @@ class Tabs extends ImmutableComponent {
this.tabRefs = []
const index = this.props.previewTabPageIndex !== undefined
? this.props.previewTabPageIndex : this.props.tabPageIndex
return <div className='tabs'>
return <div className='tabs'
onMouseLeave={this.props.fixTabWidth ? this.onMouseLeave : null}>
<span className={cx({
tabStripContainer: true,
isPreview: this.props.previewTabPageIndex !== undefined,
Expand All @@ -125,6 +140,8 @@ class Tabs extends ImmutableComponent {
paintTabs={this.props.paintTabs}
previewTabs={this.props.previewTabs}
isActive={this.props.activeFrameKey === tab.get('frameKey')}
onFrameClose={this.onFrameClose}
tabWidth={this.props.fixTabWidth}
partOfFullPageSet={this.props.partOfFullPageSet} />)
}
{(() => {
Expand Down
1 change: 1 addition & 0 deletions js/components/tabsToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class TabsToolbar extends ImmutableComponent {
previewTabPageIndex={this.props.previewTabPageIndex}
startingFrameIndex={startingFrameIndex}
partOfFullPageSet={currentTabs.size === this.props.tabsPerTabPage}
fixTabWidth={this.props.fixTabWidth}
/>
<TabsToolbarButtons
noFrames={currentTabs.size === 0}
Expand Down
4 changes: 3 additions & 1 deletion js/constants/windowConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ const windowConstants = {
WINDOW_WIDEVINE_SITE_ACCESSED_WITHOUT_INSTALL: _,
WINDOW_WIDEVINE_PANEL_DETAIL_CHANGED: _,
WINDOW_AUTOFILL_SELECTION_CLICKED: _,
WINDOW_AUTOFILL_POPUP_HIDDEN: _
WINDOW_AUTOFILL_POPUP_HIDDEN: _,
WINDOW_TAB_CLOSE: _,
WINDOW_TAB_MOUSE_LEAVE: _
}

module.exports = mapValuesByKeys(windowConstants)
8 changes: 8 additions & 0 deletions js/stores/windowStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@ const doAction = (action) => {
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
}
Expand Down

0 comments on commit ddeb75c

Please sign in to comment.