Skip to content

support icons in context menus#304906

Open
jogibear9988 wants to merge 1 commit intomicrosoft:mainfrom
jogibear9988:supportContextMenuIcons
Open

support icons in context menus#304906
jogibear9988 wants to merge 1 commit intomicrosoft:mainfrom
jogibear9988:supportContextMenuIcons

Conversation

@jogibear9988
Copy link
Contributor

fixes #304904

This will add icons support to context menus.
Commands wich have icons will already show them in the context menu.

image

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds icon rendering support to the monaco-menu context menu widget so that actions which already provide an icon CSS class can display that icon in context menus (fixes #304904).

Changes:

  • Enable icon rendering for menu items when an action provides a CSS class (icon class).
  • Add a dedicated DOM element (.menu-item-icon) to render the icon separately from the label.
  • Introduce menu CSS to position/size the icon column and handle disabled/checked visual states.

Comment on lines 409 to 416
} else {
const keybindingLabel = options.getKeyBinding?.(action)?.getLabel();
const menuItemOptions: IMenuItemOptions = {
enableMnemonics: options.enableMnemonics,
useEventAsContext: options.useEventAsContext,
keybinding: keybindingLabel,
icon: !!action.class,
};
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Icon rendering is only enabled for leaf actions via icon: !!action.class, but SubmenuAction items can also carry an icon class (SubmenuAction.class). Because the submenu branch constructs SubmenuMenuActionViewItem without setting an icon option, submenu entries with icons will still render without icons. Consider passing icon: !!action.class when creating SubmenuMenuActionViewItem (e.g. by spreading options and overriding icon).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they already work without a change:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contextmenus in vscode should support icons

3 participants