question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow extensions to contribute dynamic submenus

See original GitHub issue

Currently an extension’s menu and submenu contributions can only be statically defined in its package.json. At runtime the extension can use context keys it creates via the setContext command together with when clauses to hide its contributed items dynamically. But there are use-cases where the actual items cannot be predefined, and we have to resort to a QuickPick. IMO this results in a poor UX and some accessibility issues because the list of choices does not appear alongside the context menu action which triggered it.

I see two ways of solving this.

A) Allow submenu contents to be computed when the parent menu entry is selected (or perhaps merely focused).

I outlined this in https://github.com/microsoft/vscode/issues/9827#issuecomment-619989638

B) Add a setSubmenuContents equivalent to the existing setContext command.

Using this approach an extension would run the new command, specifying the id of one of the submenus it had defined in its settings.json, plus a second command argument containing the new definition of the submenu.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:49
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
DanTupcommented, Nov 9, 2020

Is this the same as https://github.com/microsoft/vscode/issues/27536? There are definitely many places I’d like dynamic menus (though not just sub-menus - for example on custom tree nodes). One argument against them in the past was making context menus slow (by doing async work), though I think in all my cases I could provide the commands up-front, just not statically (for example at the time I provide a tree node).

1reaction
vscode-triage-botcommented, Jan 5, 2021

🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contribution Points | Visual Studio Code Extension API
Your extension registers Contribution Points to extend various functionalities within Visual Studio Code. Here is a list of all available Contribution ...
Read more >
Writing Visual Studio Extensions with Mads - YouTube
Writing Visual Studio Extensions with Mads - Dynamically add menu commands. 5.7K views Streamed 1 year ago. Microsoft Visual Studio.
Read more >
Adding Menus to the Navigation Area - Business Central
The submenu items can include page extensions and other objects like reports, XMLPorts, and codeunits. The Dynamics NAV Client connected to ...
Read more >
How to create dynamic menus / submenus? - Joomla! Forum
When clicking on "Key concepts -> Extensions", one of the three menus ... "Select menu item(s) from the list" allows you to manually...
Read more >
Dynamically add SubMenuItems to a SubMenu - Stack Overflow
Try casting the selected DropDownItem item to a ToolStripMenuItem: ((ToolStripMenuItem)CompanyToolStripMenuItem. DropDownItems[0]).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found