Route menu ids ahead of app keyword aliases (#6563)
An installed app whose .desktop Keywords contain a menu id captured the route: htop ships Keywords=system;..., so SUPER+ESCAPE opened an empty "Htop" menu instead of the System menu once the Apps menu had merged its rows. Exact ids now win, and app rows are no longer routable at all — their keywords remain search-only. Fixes #6554 Reported-by: Craig Derington (https://github.com/craigderington) Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
4c4e17077f
commit
0269fe0031
@@ -841,17 +841,7 @@ Item {
|
||||
// in JSONC (`power`, `reminder-set`). Unknown strings fall through to the
|
||||
// id-as-route behavior so misspellings still attempt to open the literal id.
|
||||
function resolveRoute(input) {
|
||||
var raw = String(input || "").toLowerCase().replace(/_/g, "-")
|
||||
if (!raw || raw === "go" || raw === "menu") return "root"
|
||||
for (var i = 0; i < root.itemOrder.length; i++) {
|
||||
var entry = root.items[root.itemOrder[i]]
|
||||
if (!entry || !entry.aliases) continue
|
||||
for (var j = 0; j < entry.aliases.length; j++) {
|
||||
var alias = String(entry.aliases[j] || "").toLowerCase().replace(/_/g, "-")
|
||||
if (alias === raw) return entry.id
|
||||
}
|
||||
}
|
||||
return raw
|
||||
return MenuModel.resolveRoute(root.items, root.itemOrder, input)
|
||||
}
|
||||
|
||||
function openRoute(initialMenu) {
|
||||
|
||||
@@ -167,6 +167,28 @@ function item(items, id) {
|
||||
return items && items[id] ? items[id] : null
|
||||
}
|
||||
|
||||
// Routes may name a real id (`system`, `setup.power`) or an alias declared in
|
||||
// JSONC (`power-menu`, `settings`). An exact id beats any alias, and app rows
|
||||
// are never routable: their aliases carry .desktop Keywords and GenericName
|
||||
// for search, so an installed application could otherwise shadow a menu route
|
||||
// (htop ships `Keywords=system;...`). Unknown strings fall through as the
|
||||
// literal input so misspellings still attempt to open that id.
|
||||
function resolveRoute(items, itemOrder, input) {
|
||||
var raw = String(input || "").toLowerCase().replace(/_/g, "-")
|
||||
if (!raw || raw === "go" || raw === "menu") return "root"
|
||||
if (item(items, raw)) return raw
|
||||
var order = Array.isArray(itemOrder) ? itemOrder : []
|
||||
for (var i = 0; i < order.length; i++) {
|
||||
var entry = item(items, order[i])
|
||||
if (!entry || entry.kind === "app" || !entry.aliases) continue
|
||||
for (var j = 0; j < entry.aliases.length; j++) {
|
||||
var alias = String(entry.aliases[j] || "").toLowerCase().replace(/_/g, "-")
|
||||
if (alias === raw) return entry.id
|
||||
}
|
||||
}
|
||||
return raw
|
||||
}
|
||||
|
||||
function slugify(value) {
|
||||
return String(value || "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "item"
|
||||
}
|
||||
@@ -360,6 +382,7 @@ if (typeof module !== "undefined") {
|
||||
mergeAppRows: mergeAppRows,
|
||||
swapProviderRows: swapProviderRows,
|
||||
item: item,
|
||||
resolveRoute: resolveRoute,
|
||||
slugify: slugify,
|
||||
depthFor: depthFor,
|
||||
pathFor: pathFor,
|
||||
|
||||
Reference in New Issue
Block a user