Skip to content

Commit

Permalink
fix: make windowMenu role correct on MacOS (#15930)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Dec 3, 2018
1 parent 3ddd917 commit a1a431e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 31 deletions.
27 changes: 1 addition & 26 deletions default_app/menu.js
Expand Up @@ -69,15 +69,7 @@ const setDefaultApplicationMenu = () => {
]
},
{
role: 'window',
submenu: [
{
role: 'minimize'
},
{
role: 'close'
}
]
role: 'windowMenu'
},
{
role: 'help',
Expand Down Expand Up @@ -158,23 +150,6 @@ const setDefaultApplicationMenu = () => {
}
]
})
template[3].submenu = [
{
role: 'close'
},
{
role: 'minimize'
},
{
role: 'zoom'
},
{
type: 'separator'
},
{
role: 'front'
}
]
} else {
template.unshift({
label: 'File',
Expand Down
14 changes: 10 additions & 4 deletions lib/browser/api/menu-item-roles.js
Expand Up @@ -216,17 +216,23 @@ const roles = {
role: 'minimize'
},
{
role: 'close'
role: 'zoom'
},

process.platform !== 'darwin' ? {
label: 'close'
} : null,
process.platform === 'darwin' ? {
type: 'separator'
} : null,

process.platform === 'darwin' ? {
role: 'front'
} : null,
process.platform === 'darwin' ? {
type: 'separator'
} : null,
process.platform === 'darwin' ? {
role: 'window'
} : null

]
}
}
Expand Down
5 changes: 4 additions & 1 deletion spec/api-menu-item-spec.js
Expand Up @@ -349,11 +349,14 @@ describe('MenuItems', () => {

expect(item.label).to.equal('Window')
expect(item.submenu.items[0].role).to.equal('minimize')
expect(item.submenu.items[1].role).to.equal('close')
expect(item.submenu.items[1].role).to.equal('zoom')

if (process.platform === 'darwin') {
expect(item.submenu.items[2].type).to.equal('separator')
expect(item.submenu.items[3].role).to.equal('front')

expect(item.submenu.items[4].type).to.equal('separator')
expect(item.submenu.items[5].role).to.equal('window')
}
})

Expand Down

0 comments on commit a1a431e

Please sign in to comment.