nwjs / nw.js

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
https://nwjs.io
MIT License
40.42k stars 3.88k forks source link

MacOS: MenuBar replaced with default on nw.Window.open() #6333

Open scottnonnenberg opened 6 years ago

scottnonnenberg commented 6 years ago

NWJS Version : 0.27.1-sdk Operating System : MacOS 10.11.6

Expected behavior

I installed a new, custom menu. I expect that to remain even if I open a new window.

Actual behavior

If you set window: { show: false } in your package.json (so the window is responsible for showing itself after launch) then open a sub-window, the main global menu is reset to the default menu you get if you don't customize anything.

How to reproduce

Open the attached archive, and run nw . in the same directory as the package.json. Note the structure of the top-level menu. Then, click the link. Note that the top-level menu changes.

Now, close the app. Change to show: true in package.json and try it again. Note that the menu does not change this time.

Archive.zip

Christywl commented 6 years ago

I can reproduce this issue on Mac with nwjs-sdk-v0.27.2. Not reproduce on Linux/Windows.

tphalp commented 5 years ago

This bug recently bit us.

nwjs-sdk-v0.35.5 - MacOS 10.13.6

Edit: More info....

We actually use the default menus, but we noticed that when this bug occurs, the hotkeys stop working for the actions in the App Menu. Like, Cmd-Q no longer works, AND it is actually missing from the menu. So, if you look at the menu, normally it will show the hotkeys in the menu, but after opening a new window, the hotkeys are missing from the menu, and they don't work anymore either.

semmel commented 5 years ago

This seems to be fixed with the NW2 renderer "chromium-args": "--enable-features=nw2" on nwjs v0.42.3 Mac OS 10.14.6! 👍

To see, just add the line to package.json in @scottnonnenberg 's demo.

If adding the mac built-in Edit or Window menus using menubar.createMacBuiltin however, that call MUST PRECEDE any menubar.append() calls or the menus get mixed up.

In index.html

menubar.createMacBuiltin("delete-later"); // must come first!!
menubar.append(new nw.MenuItem({ label: 'File', submenu: file })); 
menubar.append(new nw.MenuItem({ label: 'View', submenu: view }));

Edit 7th March 2022:

It is still not fixed in nwjs v0.62.0

galsasson commented 4 years ago

This is still an issue for me when I create the menubar BEFORE the window is shown. To reproduce:

  1. Open a main window (hidden)
  2. Create a custom menubar
  3. Show the main window
  4. Open a secondary window without a menubar

Following this I get the default builtin menubar which persist also when closing the secondary window, preventing me from accessing the main window menubar.

If I switch steps 2 and 3 (showing the main window before creating my custom menubar) this issue doesn't happen.

NWJS Version: 0.45.6 OS: MacOS 10.12.6

semmel commented 2 years ago

This issue (+ workaround switching steps 2 and 3) still occurs with nwjs v0.62.0 on MacOS 11.6.4

semmel commented 1 year ago

This issue (+ workaround switching steps 2 and 3) still occurs with nwjs v0.82.0 on MacOS v12.7.1