From 7798ed34b1d7305086ff175cbfc6209e70addc3e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 23 Jul 2026 16:32:31 -0700 Subject: [PATCH] Keep apps menu alphabetically sorted --- shell/plugins/menu/Menu.qml | 16 ++++++++++++++++ test/shell.d/app-search-test.sh | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/shell/plugins/menu/Menu.qml b/shell/plugins/menu/Menu.qml index 527a2296..ea505f9d 100644 --- a/shell/plugins/menu/Menu.qml +++ b/shell/plugins/menu/Menu.qml @@ -549,6 +549,22 @@ Item { if (!root.isVisible(child)) continue rows.push(root.displayRow(child, child.description, child.order)) } + + // DesktopEntries can reorder its values when an application starts. + // Keep the Apps menu alphabetical independently of provider refreshes. + if (active === "apps") { + rows.sort(function(a, b) { + var aLabel = String(a.label || "").toLowerCase() + var bLabel = String(b.label || "").toLowerCase() + if (aLabel < bLabel) return -1 + if (aLabel > bLabel) return 1 + var aId = String(a.itemId || "") + var bId = String(b.itemId || "") + if (aId < bId) return -1 + if (aId > bId) return 1 + return 0 + }) + } } for (var k = 0; k < rows.length; k++) displayModel.append(rows[k]) diff --git a/test/shell.d/app-search-test.sh b/test/shell.d/app-search-test.sh index 1294dd38..44c13bc8 100644 --- a/test/shell.d/app-search-test.sh +++ b/test/shell.d/app-search-test.sh @@ -109,6 +109,11 @@ assert( 'app library fallback icon index includes device icons' ) +assert( + /if \(active === "apps"\) \{[\s\S]*?rows\.sort\(function\(a, b\)/.test(menuQml), + 'apps menu enforces alphabetical display order after provider refreshes' +) + const iconSourceMatch = appLibraryQml.match(/function iconSource\(icon\) \{([\s\S]*?)\n \}/) assert(iconSourceMatch, 'app library iconSource function exists') assert(