From 6af7e4195d6569f74b63927e2b2327fe7de461f4 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 2 Feb 2018 13:23:29 +0100 Subject: [PATCH] MOBILE-2335 contextmenu: Sort context menu items --- src/components/context-menu/context-menu.ts | 5 +++++ src/core/contentlinks/providers/delegate.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/context-menu/context-menu.ts b/src/components/context-menu/context-menu.ts index 89857016b..7c96cfcd6 100644 --- a/src/components/context-menu/context-menu.ts +++ b/src/components/context-menu/context-menu.ts @@ -43,6 +43,11 @@ export class CoreContextMenuComponent implements OnInit { this.hideMenu = !this.items.some((item) => { return !item.hidden; }); + + // Sort the items by priority. + this.items.sort((a, b) => { + return a.priority <= b.priority ? 1 : -1; + }); }); } diff --git a/src/core/contentlinks/providers/delegate.ts b/src/core/contentlinks/providers/delegate.ts index dc293023a..5aecc1f5a 100644 --- a/src/core/contentlinks/providers/delegate.ts +++ b/src/core/contentlinks/providers/delegate.ts @@ -301,7 +301,7 @@ export class CoreContentLinksDelegate { // Sort by priority. actions = actions.sort((a, b) => { - return a.priority >= b.priority ? 1 : -1; + return a.priority <= b.priority ? 1 : -1; }); // Fill result array.