electron: Cannot change the `enabled` state of a menu item on Linux
- Electron version: 1.8.2
- Operating system: Mac OS X Sierra, Ubuntu Linux 16.04, Windows 7
Test case
package.json
{
"name": "ElectronMenuBug",
"version": "0.0.1",
"main": "index.js",
"dependencies": {
"electron": "^1.8.2"
}
}
index.js
const {app, Menu, BrowserWindow} = require('electron')
app.on('ready', () => {
let menu
const template = [{
label: 'File',
submenu: [{
label: 'Foo',
id: 'foo',
click: () => {
const menuItem = menu.getMenuItemById('bar')
menuItem.enabled = true
}
}, {
label: 'Bar',
id: 'bar',
enabled: false
}]
}]
menu = Menu.buildFromTemplate(template)
const win = new BrowserWindow({ width: 300, height: 300 })
win.loadURL('about:blank')
Menu.setApplicationMenu(menu)
})
Expected behavior
After clicking on the first menu item, the second menu item should be enabled.
Actual behavior
This code works fine on Mac OS X and Windows, but it does not work on Ubuntu Linux 16.04. The menu item desperately stays disabled.
How to reproduce
Using the code above, simply type the following in the same directory:
$ npx electron .
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (9 by maintainers)
There have never been a problem with Gnome 3.x, so it’s normal that everything works OK there.
The problem occurs on Ubuntu Unity, the default DE from Ubunu 16.04, and is still not resolved.