fix: make windowMenu role correct on MacOS (#15930)

This commit is contained in:
Shelley Vohr 2018-12-03 11:52:46 -08:00 committed by GitHub
parent 3ddd917ff4
commit a1a431eb87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 31 deletions

View file

@ -69,15 +69,7 @@ const setDefaultApplicationMenu = () => {
] ]
}, },
{ {
role: 'window', role: 'windowMenu'
submenu: [
{
role: 'minimize'
},
{
role: 'close'
}
]
}, },
{ {
role: 'help', role: 'help',
@ -158,23 +150,6 @@ const setDefaultApplicationMenu = () => {
} }
] ]
}) })
template[3].submenu = [
{
role: 'close'
},
{
role: 'minimize'
},
{
role: 'zoom'
},
{
type: 'separator'
},
{
role: 'front'
}
]
} else { } else {
template.unshift({ template.unshift({
label: 'File', label: 'File',

View file

@ -216,17 +216,23 @@ const roles = {
role: 'minimize' role: 'minimize'
}, },
{ {
role: 'close' role: 'zoom'
}, },
process.platform !== 'darwin' ? {
label: 'close'
} : null,
process.platform === 'darwin' ? { process.platform === 'darwin' ? {
type: 'separator' type: 'separator'
} : null, } : null,
process.platform === 'darwin' ? { process.platform === 'darwin' ? {
role: 'front' role: 'front'
} : null,
process.platform === 'darwin' ? {
type: 'separator'
} : null,
process.platform === 'darwin' ? {
role: 'window'
} : null } : null
] ]
} }
} }

View file

@ -349,11 +349,14 @@ describe('MenuItems', () => {
expect(item.label).to.equal('Window') expect(item.label).to.equal('Window')
expect(item.submenu.items[0].role).to.equal('minimize') 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') { if (process.platform === 'darwin') {
expect(item.submenu.items[2].type).to.equal('separator') expect(item.submenu.items[2].type).to.equal('separator')
expect(item.submenu.items[3].role).to.equal('front') 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')
} }
}) })