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

[scm] the order of icon in scm is different in Chrom and Firefox #5620

Closed
kpge opened this issue Jul 2, 2019 · 8 comments · Fixed by #5624
Closed

[scm] the order of icon in scm is different in Chrom and Firefox #5620

kpge opened this issue Jul 2, 2019 · 8 comments · Fixed by #5624
Assignees
Labels
bug bugs found in the application shell issues related to the core shell

Comments

@kpge
Copy link
Contributor

kpge commented Jul 2, 2019

Description

the order of command icon in scm is different in Chrom and Firefox
git action icon diff in firefox chrome

Reproduction Steps

  • open instance in chrome and firefox
  • open scm

OS and Theia version:

  • OS: ubuntu18
  • chrome: 75.0.3770.100
  • firefox: 60.7.2esr
  • theia :latest
    Diagnostics:
@akosyakov akosyakov added browser/firefox issues related to the firefox browser bug bugs found in the application help wanted issues meant to be picked up, require help scm issues related to the source control manager labels Jul 2, 2019
@akosyakov
Copy link
Member

@kpge Will you have chance to investigate the cause? PRs are welcomed if they don't involve big structural changes.

@vince-fugnitto
Copy link
Member

It doesn't look like a problem for the scm widget but generally to all toolbar items.
It looks like chrome and firefox differ from the priority and will be reverses of each other.

For example, in the search-in-workspace widget:

Firefox
image

Chrome
image

@akosyakov akosyakov added shell issues related to the core shell and removed scm issues related to the source control manager labels Jul 2, 2019
@kpge
Copy link
Contributor Author

kpge commented Jul 2, 2019

I think the problem is here :
image

the sort funtion in Chrome and Firefox has diffenrent behavior

  • Chrome:
    image
  • Firefox:
    image

@kittaakos
Copy link
Contributor

Isn’t the comparator function the strange? Assuming I have left and right with the following items:

"{"id":"search-in-workspace.refresh","command":"search-in-workspace.refresh","tooltip":"Refresh","priority":0}"
"{"id":"search-in-workspace.clear-all","command":"search-in-workspace.clear-all","tooltip":"Clear Search Results","priority":1}"

When I compare them, them following branch will return with 1:

        if (left.group === undefined || left.group === 'navigation') {
            return 1;
        }

Meaning that left is greater than right, hence it should come after right, but the priority is the other way and ignored.

@akosyakov akosyakov removed the browser/firefox issues related to the firefox browser label Jul 2, 2019
@kittaakos
Copy link
Contributor

Also, I have managed to "break it" on Chrome:
Screen Shot 2019-07-02 at 15 11 25

@akosyakov
Copy link
Member

Could someone look at the comparator? It seems to be relatively easy fix. The logic should be following:

  • items should be compare by groups first
  • navigator group is special and always have the higher priority
  • undefined group is navigator group as well
  • if items have the same group then priority should be used for comparison within the group

It seems that the last point is not true for items within the navigator group.

@kittaakos
Copy link
Contributor

diff --git a/packages/core/src/browser/shell/tab-bar-toolbar.tsx b/packages/core/src/browser/shell/tab-bar-toolbar.tsx
index 8978286cc..a6caeaccd 100644
--- a/packages/core/src/browser/shell/tab-bar-toolbar.tsx
+++ b/packages/core/src/browser/shell/tab-bar-toolbar.tsx
@@ -292,26 +292,18 @@ export namespace TabBarToolbarItem {
      */
     export const PRIORITY_COMPARATOR = (left: TabBarToolbarItem, right: TabBarToolbarItem) => {
         // The navigation group is special as it will always be sorted to the top/beginning of a menu.
-        if (left.group === undefined || left.group === 'navigation') {
-            return 1;
-        }
-        if (right.group === undefined || right.group === 'navigation') {
-            return -1;
-        }
-        if (left.group && right.group) {
-            if (left.group < right.group) {
-                return -1;
-            } else if (left.group > right.group) {
-                return 1;
-            } else {
-                return 0;
+        const compareGroup = (leftGroup: string | undefined = 'navigation', rightGroup: string | undefined = 'navigation') => {
+            if (leftGroup === 'navigation') {
+                return rightGroup === 'navigation' ? 0 : -1;
             }
-        }
-        if (left.group) {
-            return -1;
-        }
-        if (right.group) {
-            return 1;
+            if (rightGroup === 'navigation') {
+                return leftGroup === 'navigation' ? 0 : 1;
+            }
+            return leftGroup.localeCompare(rightGroup);
+        };
+        const result = compareGroup(left.group, right.group);
+        if (result !== 0) {
+            return result;
         }
         return (left.priority || 0) - (right.priority || 0);
     };

?

@kittaakos
Copy link
Contributor

I will take care of it.

@akosyakov akosyakov removed the help wanted issues meant to be picked up, require help label Jul 2, 2019
kittaakos pushed a commit that referenced this issue Jul 2, 2019
Closes #5620.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
kittaakos pushed a commit that referenced this issue Jul 2, 2019
Closes #5620.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
kittaakos pushed a commit that referenced this issue Jul 2, 2019
Closes #5620.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application shell issues related to the core shell
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants