Skip to content
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

Core: Do no expand the widgets on the side-bars for the context menu #6965

Merged
merged 1 commit into from
Sep 3, 2020

Conversation

Anasshahidd21
Copy link
Contributor

@Anasshahidd21 Anasshahidd21 commented Jan 24, 2020

What it does

Fixes: #4367

With this PR, upon triggering the context menu, the widget is not activated. This helps perform commands on the context menu without actually giving focus to the widget.

Context menu commands analysed and affected with this change

  • Close

  • Close Others

  • Close to the right

  • Close All

  • Toggle Maximized

  • Reveal in Explorer

  • Collapse

Signed-off-by: Muhammad Anas Shahid muhammad.shahid@ericsson.com

How to test

Use Case Current Master Updated Changes
Open two files, right click on the unfocused one and click close Right clicking the tab, also reveals the tab and makes it the currentWidget The right clicked tab will not be take focus and still will be able to close the tab
Open two files, right click on the unfocused one and click close others Right clicking the tab, also reveals the tab and makes it the currentWidget and then closes the other tabs The right clicked tab will not take focus and still will be able to close all other tabs
Open two files, right click on the unfocused one and click close to the right (make sure there are tabs open to the right, else the option wont be enabled) Right clicking the tab, also reveals the tab and makes it the currentWidget and then closes the other tabs The right clicked tab will not take focus and still will be able to close the tab available on the right
Open two files, right click on the unfocused one and Toggle Maximized Right clicking the tab, also reveals the tab and makes it the currentWidget and then Maximizes the currentWidget The right clicked tab will not take focus and still will be able to maximize the right clicked widget
Open two files, right click on the unfocused one and Reveal In Explorer Right clicking the tab, also reveals the tab and makes it the currentWidget and then reveals in the file-explorer The right clicked tab will not take focus and still will be able to reveal the right clicked tab on the file-explorer
Note: 

- The above mentioned test cases must also work for the terminal view and the sidebar view

- The keybindings for `Toggle Maximized`, `Collapse` and `Reveal In Explorer` must also work 

Review checklist

Reminder for reviewers

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

Unfortunately, it does not work in all cases. Sometimes when using the context-menu to close a view, the previously active view is closed instead. There looks to me more work involved:

a

Here I moved my changelog.md to the sidepanel, and my explorer was previously active.
Using the context-menu to try and close the changelog.md results in the explorer being closed instead.

@vince-fugnitto
Copy link
Member

The main issue is that it is broken for editors, even in the main-area:

b

@Anasshahidd21
Copy link
Contributor Author

@vince-fugnitto I have fixed the issue and am ready for review.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

There are still regressions with the following approach versus master.
Commands such as Reveal in Explorer and Toggle Maximized no longer work reliably.

In the following case, the console should be maximized but it is the active editor instead which has an odd UX:

c

@akosyakov akosyakov added the shell issues related to the core shell label Jan 25, 2020
@lmcbout
Copy link
Contributor

lmcbout commented Jan 28, 2020

There are conflicts. Need to rebase to latest master

@Anasshahidd21
Copy link
Contributor Author

@vince-fugnitto, can you review the updated changes?

@Anasshahidd21 Anasshahidd21 force-pushed the anas/issueUI branch 5 times, most recently from d4b49e1 to faf5af7 Compare March 10, 2020 15:34
@Anasshahidd21
Copy link
Contributor Author

@lmcbout can you review?

@akosyakov
Copy link
Member

akosyakov commented Mar 12, 2020

@Anasshahidd21 a change breaking context menu is still not reverted, with this PR the current widget won't be proper.

@akosyakov
Copy link
Member

Screenshot 2020-03-12 at 09 15 21

Reveal in explorer is missing.

If you want to remove an activation of tabs then the proper process:

  • identify all menu paths for tabs' context menus
  • identify all added commands
  • change a command that they can work with event and without
    • so test 3 cases for each command in each area:
      • tab in focus
      • tab not in focus
      • command palette
      • maybe more cases if a command used somewhere else like in the toolbar contribution (work with code, analyze it)
  • write in CHANGELOG why do we break, how it should be fixed by extenders based on your experience above

@lmcbout
Copy link
Contributor

lmcbout commented Mar 12, 2020

As mentioned by @akosyakov , the menu item "Reveal in Explorer " is not available if I put the focus on the preference editor and try to open the context menu after. See video.
Missing Reveal

@Anasshahidd21 Anasshahidd21 force-pushed the anas/issueUI branch 2 times, most recently from fedeb34 to c0137d8 Compare March 23, 2020 15:20
@Anasshahidd21 Anasshahidd21 force-pushed the anas/issueUI branch 2 times, most recently from d478265 to 6526086 Compare March 23, 2020 19:48
import { ApplicationShell } from './shell/application-shell';

@injectable()
export class ContextMenuService {
Copy link
Member

Choose a reason for hiding this comment

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

It looks weird. ContextMenuService will be responsible to open and close context menus, not a bunch of utility methods.

That should belong to ApplicationShell.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should just delete this class and rewrite commands with existing APIs, there are enough already of them.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

@Anasshahidd21 keybindings for tabbar context-menu items are broken with this pull-request.
For example, try to toggle maximized using the keybinding on master versus this pull-request.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
packages/core/src/browser/shell/application-shell.ts Outdated Show resolved Hide resolved
@Anasshahidd21 Anasshahidd21 force-pushed the anas/issueUI branch 2 times, most recently from b5b9cb6 to 9d33d71 Compare July 6, 2020 05:58
@Anasshahidd21
Copy link
Contributor Author

@akosyakov @vince-fugnitto @lmcbout @marechal-p thank you for your past reviews. I have updated the code to address the comments, and I am ready for another review.

@akosyakov
Copy link
Member

Changes look good if there are no any other affected commands.

Copy link
Contributor

@kaiyue0329 kaiyue0329 left a comment

Choose a reason for hiding this comment

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

The changes work well 👍 ! Tested all the use cases mentioned above for the main view container, the bottom panel and the sidebar view. The keybindings for Toggle Maximized, Collapse and Reveal In Explorer also work correctly.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

I verified the functionality (both browser and electron) and it works well.
I'd like for others to review as well, perhaps you'd like to @kittaakos I believe you opened the original issue.

@Anasshahidd21 Anasshahidd21 force-pushed the anas/issueUI branch 3 times, most recently from 9ceaaa3 to f10da77 Compare August 21, 2020 05:55
@kittaakos
Copy link
Contributor

Let's fix the linter error:

diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts
index 33eacca0c..0bd3ca0c5 100644
--- a/packages/core/src/browser/common-frontend-contribution.ts
+++ b/packages/core/src/browser/common-frontend-contribution.ts
@@ -18,7 +18,7 @@
 
 import debounce = require('lodash.debounce');
 import { injectable, inject } from 'inversify';
-import { TabBar, Widget, Title } from '@phosphor/widgets';
+import { TabBar, Widget } from '@phosphor/widgets';
 import { MAIN_MENU_BAR, MenuContribution, MenuModelRegistry } from '../common/menu';
 import { KeybindingContribution, KeybindingRegistry } from './keybinding';
 import { FrontendApplicationContribution } from './frontend-application';

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

I tried it out with the electron example, the widgets do not expand on context menu render. I left a few comments, it's up to you if you want to consider them. Thank you for the fix, @Anasshahidd21! Please resolve the linter error.

* @param event used to find the selected widget.
*/
private toggleMaximized(event?: Event): void {
if (event && event.target) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor]: if (event?.target instanceof HTMLElement), and you can get rid of the static cast below.

* @returns the selected tab-bar, else returns the currentTabBar.
*/
findTabBar(event?: Event): TabBar<Widget> | undefined {
if (event && event.target) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor]: Same as above: if (event?.target instanceof HTMLElement).

findTitle(tabBar: TabBar<Widget>, event?: Event): Title<Widget> | undefined {
if (event && event.target) {
let tabNode: HTMLElement | null = event.target as HTMLElement;
while (tabNode && !tabNode.classList.contains('p-TabBar-tab')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[minor]: Can we use closest? But I am fine with the current logic too.

@Anasshahidd21 Anasshahidd21 force-pushed the anas/issueUI branch 4 times, most recently from 2155a89 to 976a752 Compare August 21, 2020 15:44
@vince-fugnitto
Copy link
Member

@akosyakov @kittaakos is there any objection to merge the pull-request, or should we wait after the release?

@kittaakos
Copy link
Contributor

@kittaakos is there any objection to merge the pull-request

I do not mind merging it. If you're unsure, you can wait.

@vince-fugnitto
Copy link
Member

I'll merge tomorrow if there are no objections 👍

Fixes: eclipse-theia#4367

Before, right clicking on different menus would focus the menu item and open it, however this should not be the case. There was a dangling code in the handleContextMenu which causes this effect, as it was checking for the id when right clicked and looked up the ID for the menu-item and set the current title to the menu-item.

Signed-off-by: Muhammad Anas Shahid <muhammad.shahid@mail.mcgill.ca>
@vince-fugnitto
Copy link
Member

Merging 🍾

@vince-fugnitto vince-fugnitto merged commit 636b181 into eclipse-theia:master Sep 3, 2020
@vince-fugnitto vince-fugnitto deleted the anas/issueUI branch September 3, 2020 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shell issues related to the core shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ui/ux] Do no expand the widgets on the side-bars for the context menu
7 participants