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

feat: show other new tab options on long click on new tab button, closes #4398 #4399

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions js/components/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const windowActions = require('../actions/windowActions')
const windowStore = require('../stores/windowStore')
const dragTypes = require('../constants/dragTypes')
const cx = require('../lib/classSet')
const contextMenus = require('../contextMenus')

const Button = require('./button')
const LongPressButton = require('./longPressButton')
const Tab = require('./tab')
const dnd = require('../dnd')
const dndData = require('../dndData')
Expand Down Expand Up @@ -87,6 +88,10 @@ class Tabs extends ImmutableComponent {
windowActions.newFrame()
}

onNewTabLongPress (rect) {
contextMenus.onNewTabContextMenu(rect)
}

render () {
this.tabRefs = []
const index = this.props.previewTabPageIndex !== undefined
Expand Down Expand Up @@ -125,10 +130,15 @@ class Tabs extends ImmutableComponent {
onClick={this.onNextPage} />
}
})()}
<Button label='+'

<LongPressButton
label='+'
l10nId='newTabButton'
className='navbutton newFrameButton'
onClick={this.newTab} />
className='browserButton navbutton newFrameButton'
disabled={false}
onClick={this.newTab}
onLongPress={this.onNewTabLongPress}
/>
</span>
</div>
}
Expand Down
20 changes: 20 additions & 0 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,15 @@ function getMisspelledSuggestions (selection, isMisspelled, suggestions) {
return items
}

function newTabMenuTemplateInit (location, e) {
const template = [
CommonMenu.newPrivateTabMenuItem(),
CommonMenu.newPartitionedTabMenuItem(),
CommonMenu.newWindowMenuItem()
]
return template
}

function getEditableItems (selection, editFlags) {
const hasSelection = selection.length > 0
const hasClipboard = clipboard.readText().length > 0
Expand Down Expand Up @@ -1042,6 +1051,16 @@ function onTabContextMenu (frameProps, e) {
tabMenu.destroy()
}

function onNewTabContextMenu (rect) {
const menuTemplate = newTabMenuTemplateInit(rect)

windowActions.setContextMenuDetail(Immutable.fromJS({
left: rect.left,
top: rect.bottom + 2,
template: menuTemplate
}))
}

function onTabsToolbarContextMenu (activeFrame, closestDestinationDetail, isParent, e) {
e.stopPropagation()
const tabsToolbarMenu = Menu.buildFromTemplate(tabsToolbarTemplateInit(activeFrame, closestDestinationDetail, isParent))
Expand Down Expand Up @@ -1245,6 +1264,7 @@ module.exports = {
onHamburgerMenu,
onMainContextMenu,
onTabContextMenu,
onNewTabContextMenu,
onTabsToolbarContextMenu,
onDownloadsToolbarContextMenu,
onTabPageContextMenu,
Expand Down