-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
electron: update rendering of menu items #7869
Conversation
1feb509
to
f9d05b1
Compare
Two remarks:
|
There is another side-effect of this PR, we do not show non-enabled menu items on start, so for instance, the I tend to not accept this PR with the current state. I prefer to see the menu items even if they're NOOP than not seeing them. |
Thank you for your feedback @kittaakos!
We will need to find a solution which does not affect the main-menu, but rather only the context-menu (due to the dynamic menu issue). In VS Code, the context-menu only displays enabled menu items, it will not display no-op menu items (similarly to this pull-request).
The idea is to hide context-menu items only.
I agree, I'll need to dive deeper to see if it's possible only to modify the context-menu and not the main-menu.
I wasn't able to reproduce this issue with my changes, do you have the steps to reproduce? |
You can try resetting the workbench layout. |
Do you want to align the browser behavior with electron? AFAIK, we disable but show the context menu items in browser env. |
@kittaakos I was only planning on updating the electron target to hide disabled menu items (similarly to vscode) and not update the browser which does not have this limitation. In the browser, disabled menu items are properly decorated (grayed-out). |
👍 I am fine with it, I just wanted to know what to verify once it's ready. |
f1776cf
to
c1514fc
Compare
@kittaakos I modified the code to only affect context-menus and not the main-menu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
packages/core/src/electron-browser/menu/electron-main-menu-factory.ts
Outdated
Show resolved
Hide resolved
packages/core/src/electron-browser/menu/electron-main-menu-factory.ts
Outdated
Show resolved
Hide resolved
This commit updates the logic of rendering menu items with the electron target to be based on a command being `enabled`. Since electron does not support graying-out items (enable), we must rely on hiding these items from the menus since they are no-op when executed. Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
c1514fc
to
96cef3c
Compare
@kittaakos @akosyakov thank you for the feedback, I've updated and retested the code based on your feedback :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have checked it with the electron example; it worked as expected. Thank you! 👍
What it does
The following pull-request updates the rendering of electron context-menu items based on a command's
isEnabled
. In electron, menu items cannot be disabled (grayed-out) like the browser so we must rely on hiding elements instead of disabling them. With this change, menu items in electron are not rendered if theirisEnabled
is not true.For example, language-server commands (monaco) are always populated in electron menus which does not make sense since such commands (ex: 'go to definition') do not make sense when they are no-op. Omitting the rendering of these items also aligns with the menu behavior visible from vscode.
Master:
Pull Request:
How to test
Reset Workbench Layout
(language feature menu items should be available)
(language feature menu items should not be available)
Review checklist
Reminder for reviewers
Signed-off-by: vince-fugnitto vincent.fugnitto@ericsson.com