Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled/hidden menu appears anyway after upgrade to 4.0.0-beta.8 #15901

Closed
zadam opened this issue Nov 30, 2018 · 25 comments
Closed

Disabled/hidden menu appears anyway after upgrade to 4.0.0-beta.8 #15901

zadam opened this issue Nov 30, 2018 · 25 comments
Assignees
Labels
4-2-x 6-1-x 7-1-x 8-x-y bug/regression ↩️ A new version of Electron broke something platform/linux status/confirmed A maintainer reproduced the bug or agreed with the feature

Comments

@zadam
Copy link

zadam commented Nov 30, 2018

  • Output of node_modules/.bin/electron --version: v4.0.0-beta.8
  • Operating System (Platform and Version): Ubuntu Linux 18.10
  • Output of node_modules/.bin/electron --version on last known working Electron version (if applicable): v4.0.0-beta.7

Expected Behavior
No application menu appears.

Actual behavior
Menu appeared, additionally it's invisible before clicking on it (see screenshots).

To Reproduce

$ git clone https://github.com/zadam/trilium -b master
$ npm install
$ npm run start-electron

Screenshots

The weird thick title bar is actually a menu after clicking on it:

image

This is the menu after clicking on it:

image

Additional Information

To be clear my app doesn't have any app menu so the menu isn't enabled. This worked as expected with 4.0.0-beta.7 and earlier versions.

@welcome
Copy link

welcome bot commented Nov 30, 2018

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

@ckerr
Copy link
Member

ckerr commented Nov 30, 2018

This is possibly fixed by #15878 which will be in 4.0.0-beta.9.

Could you please retest with that once it's released?

@ckerr
Copy link
Member

ckerr commented Nov 30, 2018

OH -- also, thank you for testing your app with the betas! ❤️

@ckerr ckerr added the blocked/need-info ❌ Cannot proceed without more information label Nov 30, 2018
@zadam
Copy link
Author

zadam commented Nov 30, 2018

Yes, #15878 does explain why the menu looks invisible (font color is wrong).

But it doesn't explain why menu shows up in the first place since it's disabled and properly didn't show up in beta.7 and earlier. I create the window like this:

const win = new electron.BrowserWindow({ ... my config ... });
win.setMenu(null);

win.setMenu(null) should hide the menu AFAIK.

This was when I started electron ./node_modules/.bin/electron .
Then I thought I will also test it built with electron packager and surprisingly, that one didn't have the menu (which is correct).

So it's probably not a big issue, but still a bit surprising and it's a change from the earlier releases.

@ckerr ckerr removed the blocked/need-info ❌ Cannot proceed without more information label Nov 30, 2018
@ckerr ckerr self-assigned this Nov 30, 2018
@ckerr ckerr added bug/regression ↩️ A new version of Electron broke something status/confirmed A maintainer reproduced the bug or agreed with the feature labels Nov 30, 2018
@ckerr
Copy link
Member

ckerr commented Nov 30, 2018

This works in 6487466 but not in 7cc7d4a, so I think #15094 that caused this regression.

@nitsakh I'm happy to investigate this, but if you have an idea of the cause, do you want this ticket?

@ckerr ckerr changed the title Weird menu appears after upgrade to 4.0.0-beta.8 Disabled/hidden menu appears anyway after upgrade to 4.0.0-beta.8 Nov 30, 2018
@vladimiry
Copy link

There was the same problem introduced with 3.0.8 #15601 and it got fixed there. But now the final v4 release is affected.

@joehonton
Copy link

I can confirm that this was working in 3.10 but is not working in 4.0.0 on Windows and Linux.

var browserWindow = new Electron.BrowserWindow(options);
browserWindow.setMenu(null);

In my case I have one browser window that should have a menu and several others -- acting as modeless dialogs for preferences and tools -- that should not. I use setMenu(null) on these modeless windows.

@TheFeelTrain
Copy link

Same issue here after updating to 4.0.0 on Arch Linux with KDE Plasma 5.

@ventr1x
Copy link

ventr1x commented Jan 14, 2019

Any info regarding this?

setMenu(null) is not working at all.
Overwriting the menu template afterwards works, but results in the debug menu appearing for a few seconds until initialization.

"electron": "^4.0.1" on macOS

@andrewheadricke
Copy link

andrewheadricke commented Jan 18, 2019

stumbled onto same issue. v4.0.1 on linux

@vladimiry
Copy link

Any info regarding this?

As an ugly workaround, you can set autoHideMenuBar to true creating the BrowserWindow. So menu will remain hidden until user presses alt key.

@bluenote10
Copy link

I have a similar issue (menu is always visible despite setMenu(null), no black font color). Tested with 4.0.1 and 4.0.4 under Linux.

@Ajeey
Copy link
Contributor

Ajeey commented Mar 18, 2019

Any info regarding this?

As an ugly workaround, you can set autoHideMenuBar to true creating the BrowserWindow. So menu will remain hidden until user presses alt key.

After you've done the above, an even uglier workaround is to disable the alt key press -

document.addEventListener('keydown', (event) => {
    if(event.altKey) {
        event.preventDefault();
        return;
    }
});

Tested this on 4.0.8 and works 💃

@jacobq
Copy link
Contributor

jacobq commented Apr 8, 2019

The work-around I am using is to call win.setMenuBarVisibility(false). That seems to avoid the problem with the Alt key revealing the menu. Am I missing something?

@pronebird
Copy link

pronebird commented Apr 29, 2019

@jacobq yep you're missing the fact that it does not work on Ubuntu Linux. The only way to hide the menu is to pass autoHideMenuBar: true in Window options. win.setMenuBarVIsibility(false) does nothing at all and it's still possible to get that menu with Alt key.

@jacobq
Copy link
Contributor

jacobq commented May 3, 2019

@pronebird

it does not work on Ubuntu Linux

Really? Try my minimal demo here. It works for me on Debian. What is the difference?

GIF

animation

@Ajeey
Copy link
Contributor

Ajeey commented May 9, 2019

@jacobq Try hiding for a child window

@electron-triage
Copy link

Thank you for taking the time to report this issue and helping to make Electron better.

The version of Electron you reported this on has been superseded by newer releases.

If you're still experiencing this issue in Electron 6.x.y or later, please add a comment specifying the version you're testing with and any other new information that a maintainer trying to reproduce the issue should know.

I'm setting the blocked/need-info label for the above reasons. This issue will be closed 7 days from now if there is no response.

Thanks in advance! Your help is appreciated.

@electron-triage electron-triage added the blocked/need-info ❌ Cannot proceed without more information label Feb 19, 2020
@joehonton
Copy link

This is the code that hid the menu from the window. It was working in 3.10 but broke in 4.0.0 --

var browserWindow = new Electron.BrowserWindow(options);
browserWindow.setMenu(null);

I have just now tested this on these versions all of which still exhibit the broken behavior:

  • 4.0.1
  • 5.0.13
  • 6.1.7
  • 7.1.13
  • 8.0.1

This ticket should be kept opened.

@jacobq
Copy link
Contributor

jacobq commented Feb 21, 2020

Does the Menu.setApplicationMenu(null) work-around mentioned in the linked issue help?

@ventr1x
Copy link

ventr1x commented Feb 21, 2020

"We completely ignored this issue for nearly two years, please test again if it magically disappeared so we can keep ignoring it.Thanks, your truly. useless bot."

@joehonton
Copy link

@jacobq The Menu.setApplicationMenu(null) purported work-around does not work.

There appears to be two scenarios intermingled in this discussion. The one I'm reporting is where I have an application window that does have a menu, and a second window, for informational purposes, that does not.

This is the desired pseudo code:

menu = Electron.Menu.buildFromTemplate(template);
Electron.Menu.setApplicationMenu(menu); 
. . .
myApplicationWindow = new Electron.BrowserWindow(options);
. . .
mySecondWindow = new Electron.BrowserWindow(options);
mySecondWindow.setMenu(null);

@jacobq
Copy link
Contributor

jacobq commented Feb 21, 2020

@jacobq The Menu.setApplicationMenu(null) purported work-around does not work.

OK, so IIUC the reason in your case is that Menu.setApplicationMenu(menu) affects all windows (on Windows / Linux) but you need to control specific windows.

Would you be willing to share an electron-fiddle demonstrating the problem? I would be curious to see it since I have run into similar problems in the past but was always able to work around them somehow (e.g. wait for ready event).

@joehonton
Copy link

I have worked through the issue stripping down the code to bare essentials, TL;DR I am now satisfied that browserWindow.setMenu(null) does work as expected.

The longer story is that my app has a lengthy initialization phase (approximately 1000ms to 1500ms depending on the file it's opening), which causes a race condition between creating the menu with Electron.Menu.buildFromTemplate and creating the first and second browser windows. This triggers an occasional artifact where the setMenu(null) for the second window is overridden by setMenu(menu) being called on the first window.

It would be OK with me to close this ticket, but the real solution would be to change new BrowserWindow(options) to have an option that explicitly states that the window should not have a menu.

@electron-triage electron-triage added 6-1-x 7-1-x 8-x-y and removed blocked/need-info ❌ Cannot proceed without more information labels Feb 26, 2020
@electron-triage
Copy link

The Electron version reported on this issue is no longer supported. See our supported versions documentation.

If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.

Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4-2-x 6-1-x 7-1-x 8-x-y bug/regression ↩️ A new version of Electron broke something platform/linux status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
None yet
Development

No branches or pull requests