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

0.12.2dev titlebar fixes (round 3) #4251

Merged
merged 1 commit into from
Sep 24, 2016
Merged
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
37 changes: 22 additions & 15 deletions app/renderer/components/menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,33 @@ const separatorMenuItem = require('../../common/commonMenu').separatorMenuItem
const keyCodes = require('../../../js/constants/keyCodes')
const { wrappingClamp } = require('../../common/lib/formatUtil')

const bindClickHandler = (contextMenu, lastFocusedSelector) => {
if (contextMenu.type === separatorMenuItem.type) {
return contextMenu
}
contextMenu.click = function (e) {
e.preventDefault()
if (lastFocusedSelector) {
// Send focus back to the active web frame
const results = document.querySelectorAll(lastFocusedSelector)
if (results.length === 1) results[0].focus()
}
windowActions.clickMenubarSubmenu(contextMenu.label)
}
if (contextMenu.submenu) {
contextMenu.submenu = contextMenu.submenu.map((submenuItem) => {
return bindClickHandler(submenuItem, lastFocusedSelector)
})
}
return contextMenu
}

const showContextMenu = (rect, submenu, lastFocusedSelector) => {
windowActions.setContextMenuDetail(Immutable.fromJS({
left: rect.left,
top: rect.bottom,
template: submenu.map((submenuItem) => {
if (submenuItem.type === separatorMenuItem.type) {
return submenuItem
}
submenuItem.click = function (e) {
e.preventDefault()
if (lastFocusedSelector) {
// Send focus back to the active web frame
const results = document.querySelectorAll(lastFocusedSelector)
if (results.length === 1) {
results[0].focus()
}
}
windowActions.clickMenubarSubmenu(submenuItem.label)
}
return submenuItem
return bindClickHandler(submenuItem, lastFocusedSelector)
})
}))
}
Expand Down