eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.55k stars 2.46k forks source link

Dynamically registered menus are ignored by the menu renderer #13719

Closed msujew closed 3 weeks ago

msujew commented 2 months ago

Bug Description:

Discussed in https://github.com/eclipse-theia/theia/discussions/13716.

Registering a menu with a delay prevents that menu from showing up in the main application menu.

The issue is that the main menu is only recreated during startup and when the menu bar visibility changes. It doesn't listen on any other events.

Steps to Reproduce:

  1. Add a delay to the registerMenus method of any MenuContribution.
  2. Notice that the newly registered menu doesn't appear correctly
  3. Adjust the window.menuBarVisibility setting.
  4. The newly registered menu is now visible.

Additional Information

baoqing1124 commented 2 months ago

setTimeout(() => { menus.registerSubmenu(subSubMenuPath, 'Sample sub menu', { order: '2' }); menus.registerMenuAction(subSubMenuPath, { commandId: SampleCommand2.id, order: '3' }); const visibility = this.preferenceService.get('window.menuBarVisibility'); this.preferenceService.updateValue('window.menuBarVisibility', visibility === 'classic' ? 'visible' : 'classic') }, 5000);

@msujew Thanks for your help, I changed window.menuBarVisibility like this and it worked for me