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

Make new tab context menu native #8397

Merged
merged 1 commit into from
Apr 20, 2017
Merged
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
20 changes: 3 additions & 17 deletions js/contextMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,29 +1363,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 * () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@liunkae Was this added to the tracking ticket?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luixxiul Thanks! Added.

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