-
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
Ensure active element is preserved when opening context menu #10852
Ensure active element is preserved when opening context menu #10852
Conversation
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.
@martin-fleck-at do you have any additional details on how to reproduce the problem, the behavior as you described works fine for me on master
. I thought perhaps that no file selection should be present when performing paste
, which does not work on master, but the pull-request also does not fix it.
If there is no file selection however the paste does not work, but it is also true with this pull-request.
@vince-fugnitto Interesting. I just tested this as shown in the video. I am using the current master, building with This PR does not aim to fix the empty selection Paste (if that is even an issue), so that is fine. |
@martin-fleck-at this is master for me, I opened the dev tools to show the sources of the method in question. copy-paste-explorer.mp4 |
@vince-fugnitto Seems like I was not 100% correct about the necessary steps to reproduce this bug BUT thanks to your video I know see it. The bug happens when you use a custom title bar (Preferences > Window: Title Bar Style). In that case, the context menu seems to be rendered slightly differently. |
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.
@martin-fleck-at thank you for the follow-up I was able to reproduce finally 👍
I confirm that the changes work correctly thanks to your updates.
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.
There is a note in the code about this phenomenon. It seems we should at least remove the comment, if we are now calling preserveFocusedElement
for context menus, but it may warrant further investigation, since this bug may suggest that something about the command registry is not behaving as expected.
theia/packages/core/src/browser/menu/browser-menu-plugin.ts
Lines 259 to 260 in b8df294
// Hint: this is not called from the context menu use-case, but is not required. | |
// For the context menu the command registry state is calculated by the factory before `open`. |
@colin-grant-work I did not remove the comment because I do not actually trigger the |
@martin-fleck-at, the comment above |
@colin-grant-work I see, I interpreted it as: The |
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.
LGTM. 👍
What it does
Fixes #10851
This change ensures that the active element from the document is preserved when opening the menu. If there is already another element that is preserved, this fix simply does nothing as the previous preserved element is kept.
Please note that the top menu is not affected by this since the
aboutToShow
is called through theDynamicMenuBarWidget
.How to test
window.titleBarStyle: custom
)Review checklist
Reminder for reviewers