support icons in context menus#304906
Open
jogibear9988 wants to merge 1 commit intomicrosoft:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
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, | ||
| }; |
There was a problem hiding this comment.
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).
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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