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

Support dynamic menu contributions #13720

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

msujew
Copy link
Member

@msujew msujew commented May 17, 2024

What it does

Closes #13719

Adds a new onDidChange event to the MenuModelRegistry. Any changes to the menus (i.e. registering, unregistering, disposal) fire this event now. Adds a listener to this event in the menu factories to ensure that the menus are correctly recreated.

How to test

  1. Adjust some of the sample-menu-contribution.ts file:
setTimeout(() => {
  const disposable = menus.registerMenuAction(subSubMenuPath, {
    commandId: SampleCommand2.id,
    order: '3'
  });
  setTimeout(() => disposable.dispose(), 8000);
}, 8000);
  1. After starting the app, open the Sample Menu > Sample sub menu
  2. It should only show 2 entries
  3. After a few seconds the menu should refresh showing an additional entry
  4. A few seconds later the entry should disappear again.

Follow-ups

I've noticed that the menu flashes when the model is changed (i.e. any open main sub menus are closed). That's something that could maybe be addressed in a separate PR. A smart diffing of the menu bar HTML element would probably be appropriate here.

Review checklist

Reminder for reviewers

@msujew msujew added the menus issues related to the menu label May 17, 2024
@msujew
Copy link
Member Author

msujew commented May 17, 2024

cc @kittaakos this is maybe interesting for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
menus issues related to the menu
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

Dynamically registered menus are ignored by the menu renderer
1 participant