luci-base: ui.js: order menu entries with the same weight by name
authorJo-Philipp Wich <jo@mein.io>
Fri, 3 Jul 2020 12:30:30 +0000 (14:30 +0200)
committerJo-Philipp Wich <jo@mein.io>
Sat, 4 Jul 2020 22:11:59 +0000 (00:11 +0200)
The previous server side menu rendering ordered items first by their order
weight value, then by their internal name.

Do the same for client side menu rendering.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/ui.js

index a6598355d67a217a03c6c788e06a0fe188fed913..91a93b9e9019e01d9147cc75052106563b8367a7 100644 (file)
@@ -3053,7 +3053,13 @@ var UIMenu = baseclass.singleton(/** @lends LuCI.ui.menu.prototype */ {
                }
 
                return children.sort(function(a, b) {
-                       return ((a.order || 1000) - (b.order || 1000));
+                       var wA = a.order || 1000,
+                           wB = b.order || 1000;
+
+                       if (wA != wB)
+                               return wA - wB;
+
+                       return a.name > b.name;
                });
        }
 });