Repository navigation
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a bug report that matches the one I want to file, without success.
Electron Version
45.5.0
What operating system(s) are you using?
Ubuntu
Operating System Version
Ubuntu 26.04, GNOME 50, Wayland (the app runs with --ozone-platform=wayland)
What arch are you using?
x64
Last Known Working Electron version
Not known.
Does the issue also appear in Chromium / Google Chrome?
No
Expected Behavior
When a checkbox item of the application menu changes, because the user clicked it in the global menu or the app set menuItem.checked, the global menu shows its new state the next time the menu opens.
Actual Behavior
The global menu keeps showing the state the checkbox had when Electron last built that menu for the global menu. It shows the new state only after something changed in the menu one level above it (its parent menu, or the menu bar for a top-level menu), or after the app sets its whole menu again with Menu.setApplicationMenu().
Testcase Gist URL
Additional Information
The gist's main.js sets an application menu with an Options menu, which has a checkbox "Top Check" and a submenu Nested with a checkbox "Nested Check", and shows the state of both in the window title. 20 seconds after it starts, the app checks Nested Check itself, and 35 seconds after it starts, it disables the top-level File menu, without setting its menu again.
I read the menu which Electron exports over D-Bus, as a desktop with a global menu does: AboutToShow on Options and then GetLayout of Options, and the same for Nested, each time. With Electron 45.5.0:
| Step | Window title | Exported toggle-state of Top Check |
of Nested Check |
|---|---|---|---|
| Start | top=false nested=false |
0 | 0 |
Top Check clicked through the menu (Event "clicked") |
top=true nested=false |
0 | 0 |
| The app checked Nested Check (20 s) | top=true nested=true |
0 | 0 |
| The app disabled File (35 s) | top=true nested=true file=disabled |
1 | 1 |
The item ID of Top Check stays the same until File is disabled, so Electron did not rebuild Options before that. In a desktop's global menu, as in KDE Plasma's Global Menu widget, which reads the menu the same way, Top Check would stay unchecked after the user clicked it. I tested only by reading the menu over D-Bus, with a GNOME Shell extension which shows the exported menus.
The cause seems to be in GlobalMenuBarX11::OnSubMenuShow(). It rebuilds the children of a submenu only when GetMenuModelStatus(model) changed since the last time, but model is the model of the menu which contains the submenu item, while the children are built from model->GetSubmenuModelAt(id). So a change of the items of the submenu itself, as their checked state, but also their labels, enabled or visible state, is not noticed, and a change one level above rebuilds it. Computing the status of model->GetSubmenuModelAt(id) there would fix it. The top-level menus are submenus of the menu bar, so a checkbox directly in a top-level menu is affected too. Apps which set their whole menu again after each change do not show the problem.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields👀 Unsorted Items
Activity