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

Electron 7.1.2 - Can't remove the main BrowserWindow menu #21268

Closed
3 tasks done
JMorillasGreen opened this issue Nov 23, 2019 · 7 comments
Closed
3 tasks done

Electron 7.1.2 - Can't remove the main BrowserWindow menu #21268

JMorillasGreen opened this issue Nov 23, 2019 · 7 comments
Assignees
Labels
7-1-x bug/regression ↩️ A new version of Electron broke something platform/windows

Comments

@JMorillasGreen
Copy link

JMorillasGreen commented Nov 23, 2019

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 an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 7.1.2
  • Operating System:
    • Windows 10 1909
  • Last Known Working Electron version:
    • 7.x.x (in another Windows 10 1909 computer)

Expected Behavior

The menu that appears below the app title (the one with File, Edit, View...) must dissappear.

Actual Behavior

Nothing. It does nothing. The menu is still there. as if nothing happened.

To reproduce

This is basically the code I am testing:

const { app, BrowserWindow } = require('electron');

function createWindow() {
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
}
})
win.setMenuBarVisibility(false);
win.loadFile('./public/index.html')
}

app.on('ready', createWindow)

Everything works as expected, except the menu, which it still shows.

Screenshots

https://i.imgur.com/kJJf0JE.png

@frankhale
Copy link
Contributor

frankhale commented Nov 23, 2019

win.removeMenu() and win.setMenu(null) are not getting rid of the menu in 7.1.2. I can confirm this on the Windows build.

It works as expected in 6.1.5

@JMorillasGreen
Copy link
Author

I have tried with the latest beta, and still doesn't work. I think I will try with 6.1.5.

@JMorillasGreen
Copy link
Author

Okay, I will edit the main post, but this is what I found so far:
ElectronJS 6.1.5 - It's working.
ElectronJS 7.1.2 - It's not working.
ElectronJS 8.0.0-beta3 - It's not working.

Any ideas?

@JMorillasGreen
Copy link
Author

Okay. I managed to solve it, but I am not sure if this is how is supposed to work in 7.x.x, 8.x.x and 9.x.x.

Instead of using win.setMenuBarVisibility(true), I used autoHideMenuBar: true, in the window properties, like this:
let win = new BrowserWindow({
width: 800,
height: 600,
autoHideMenuBar: true, // ---- THIS
webPreferences: {
nodeIntegration: true,
}

@frankhale
Copy link
Contributor

frankhale commented Nov 29, 2019

autoHideMenuBar Boolean (optional) - Auto hide the menu bar unless the Alt key is pressed. Default is false.

Setting autoHideMenuBar seems like a work around because removing the menubar can be done with the removeMenu function in older Electron version. In even older Electron versions you had to set the menubar to null to remove it. In my particular case I want to remove the menubar completely and this solution would not be enough for that.

@jacobq
Copy link
Contributor

jacobq commented Dec 3, 2019

Isn't this a duplicate of #21268 #21088

@ckerr ckerr added 7-1-x bug/regression ↩️ A new version of Electron broke something platform/windows labels Dec 4, 2019
@ckerr ckerr added this to Unsorted Issues in 8.2.x Dec 4, 2019
@jkleinsc jkleinsc moved this from Unsorted Issues to Does Not Block Stable in 8.2.x Dec 4, 2019
@codebytere
Copy link
Member

Duplicate of #21088

@codebytere codebytere marked this as a duplicate of #21088 Dec 5, 2019
@codebytere codebytere removed this from Does Not Block Stable in 8.2.x Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7-1-x bug/regression ↩️ A new version of Electron broke something platform/windows
Projects
None yet
Development

No branches or pull requests

6 participants