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

Commit

Permalink
Make new tab context menu native (#8397)
Browse files Browse the repository at this point in the history
Fixes #7748
  • Loading branch information
Liunkae authored and bsclifton committed Apr 25, 2017
1 parent 7fe2517 commit 57eddd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
20 changes: 3 additions & 17 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1339,29 +1339,15 @@ function onTabContextMenu (frameProps, e) {
}

function onNewTabContextMenu (target) {
const rootElement = window.getComputedStyle(document.querySelector(':root'))
const contextMenuSize = Number.parseInt(rootElement.getPropertyValue('--context-menu-single-max-width'), 10)

const containerRect = target.parentNode.getBoundingClientRect()
const rect = target.getBoundingClientRect()

const contextMenuMaxVisibleWidth = rect.right + (contextMenuSize / 2)
const contextMenuHasOverflow = contextMenuMaxVisibleWidth > containerRect.right

const menuTemplate = [
CommonMenu.newTabMenuItem(),
CommonMenu.newPrivateTabMenuItem(),
CommonMenu.newPartitionedTabMenuItem(),
CommonMenu.newWindowMenuItem()
]

windowActions.setContextMenuDetail(Immutable.fromJS({
left: contextMenuHasOverflow
? contextMenuMaxVisibleWidth - contextMenuSize - rect.width
: rect.left,
top: rect.bottom + 2,
template: menuTemplate
}))
const menu = Menu.buildFromTemplate(menuTemplate)
menu.popup(getCurrentWindow())
menu.destroy()
}

function onTabsToolbarContextMenu (activeFrame, closestDestinationDetail, isParent, e) {
Expand Down
4 changes: 2 additions & 2 deletions test/tab-components/tabTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ describe('tab tests', function () {
.click(newFrameButton)
.waitForExist('[data-test-id="tab"][data-frame-key="2"]')
})
it('shows a context menu when long pressed (click and hold)', function * () {
it.skip('shows a context menu when long pressed (click and hold)', function * () {
yield this.app.client
.moveToObject(newFrameButton)
.buttonDown(0)
.waitForExist('.contextMenu .contextMenuItem .contextMenuItemText')
.buttonUp(0)
})
it('shows a context menu when right clicked', function * () {
it.skip('shows a context menu when right clicked', function * () {
yield this.app.client
.rightClick(newFrameButton)
.waitForExist('.contextMenu .contextMenuItem .contextMenuItemText')
Expand Down

0 comments on commit 57eddd2

Please sign in to comment.