Allow extensions to contribute dynamic submenus
See original GitHub issueCurrently 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:
- Created 3 years ago
- Reactions:49
- Comments:8 (3 by maintainers)
Top GitHub Comments
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).
🙂 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!