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

Impossible to update the menu #245

Open
Makio64 opened this issue Oct 29, 2023 · 1 comment
Open

Impossible to update the menu #245

Makio64 opened this issue Oct 29, 2023 · 1 comment

Comments

@Makio64
Copy link

Makio64 commented Oct 29, 2023

Problem Description

On recent electron version, changing the menu using the example or other methods didnt work and the menu in the title bar simply disappear.

Steps to Reproduce

	// in the main
	const menu = new Menu()
	menu.append(
		new MenuItem({
			label: 'File',
			submenu: [
				{
					label: 'Import gltf/glb',
					click: () => {
						console.log('Open File')
					},
				},
				{
					type: 'separator',
				},
				{
					label: 'Close',
					click: () => {
						win.close()
					},
				},
			],
		}),
	)
	Menu.setApplicationMenu(menu)

Expected Behavior

The title bar is updated with the new menu

Current Behavior

the menu disappear

Additional Information

  • windows 11
  • node v20.5.0
  • electron 27.0.2 / also didn't work on ^26.0.0

Note:
Labels - bug

@AlexTorresDev
Copy link
Owner

You should use titlebar.refreshMenu(), an asynchronous method that refreshes the menu with what is in Menu.getApplicationMenu(), after updating the menu with the sample code you showed above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants