From f8b2d1c2ae71eeb9d90f07bba85557beadf9fd6e Mon Sep 17 00:00:00 2001 From: Marius Lifvergren Date: Sat, 12 Sep 2026 23:08:25 +0200 Subject: [PATCH 1/2] Fix menu navigation history unconditionally resetting cursor index --- shell/plugins/menu/Menu.qml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/shell/plugins/menu/Menu.qml b/shell/plugins/menu/Menu.qml index aa879c188fd6..8a93ba14d118 100644 --- a/shell/plugins/menu/Menu.qml +++ b/shell/plugins/menu/Menu.qml @@ -726,13 +726,15 @@ Item { root.rebuildDisplay() } - function setActiveMenu(id, pushHistory, fromPointer) { + function setActiveMenu(id, pushHistory, fromPointer, restoreIndex) { panel.freezeCardTop() if (!root.item(id)) id = "root" - if (pushHistory && id !== root.activeMenu) root.navStack = root.navStack.concat([root.activeMenu]) + if (pushHistory && id !== root.activeMenu) { + root.navStack = root.navStack.concat([{ id: root.activeMenu, index: root.selectedIndex }]) + } root.activeMenu = id root.filterText = "" - root.selectedIndex = 0 + root.selectedIndex = restoreIndex !== undefined ? restoreIndex : 0 root.cursorActive = true if (fromPointer) pointerGate.allowInitialSample() else root.disarmPointer() @@ -747,7 +749,11 @@ Item { if (root.navStack.length > 0) { var previous = root.navStack[root.navStack.length - 1] root.navStack = root.navStack.slice(0, root.navStack.length - 1) - root.setActiveMenu(previous, false) + if (typeof previous === "string") { + root.setActiveMenu(previous, false) + } else { + root.setActiveMenu(previous.id, false, false, previous.index) + } return true } From aadb1f5bd5b6769573ebd82a64006c7325d350b5 Mon Sep 17 00:00:00 2001 From: Marius Lifvergren <192463151+Lifferado@users.noreply.github.com> Date: Tue, 13 Oct 2026 09:50:56 +0200 Subject: [PATCH 2/2] Restore the top row when Back leaves a filtered list setActiveMenu saved the filtered list's index and then cleared the filter, so Back applied it to the parent's unfiltered rows: searching "font" at the root and opening Install's Font, Back landed on Learn. Save index 0 when the menu being left is filtered, as before this change. Also match the new restoreIndex parameter in menu-test.sh's setActiveMenu signature check, which stopped the file at that assertion. Co-Authored-By: Claude Opus 5.5 --- shell/plugins/menu/Menu.qml | 4 +++- test/shell.d/menu-test.sh | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/plugins/menu/Menu.qml b/shell/plugins/menu/Menu.qml index 8a93ba14d118..7f99d69edfd8 100644 --- a/shell/plugins/menu/Menu.qml +++ b/shell/plugins/menu/Menu.qml @@ -730,7 +730,9 @@ Item { panel.freezeCardTop() if (!root.item(id)) id = "root" if (pushHistory && id !== root.activeMenu) { - root.navStack = root.navStack.concat([{ id: root.activeMenu, index: root.selectedIndex }]) + // A filtered list's index means nothing once the filter clears, so a + // menu left mid-search comes back at the top. + root.navStack = root.navStack.concat([{ id: root.activeMenu, index: root.filterText.trim() ? 0 : root.selectedIndex }]) } root.activeMenu = id root.filterText = "" diff --git a/test/shell.d/menu-test.sh b/test/shell.d/menu-test.sh index a424379b1afd..375b270b762d 100644 --- a/test/shell.d/menu-test.sh +++ b/test/shell.d/menu-test.sh @@ -491,7 +491,7 @@ assert( 'menu filter changes disarm pointer selection' ) assert( - /function setActiveMenu\(id, pushHistory, fromPointer\)[\s\S]*if \(fromPointer\) pointerGate\.allowInitialSample\(\)\s*else root\.disarmPointer\(\)/.test(menuQml), + /function setActiveMenu\(id, pushHistory, fromPointer, restoreIndex\)[\s\S]*if \(fromPointer\) pointerGate\.allowInitialSample\(\)\s*else root\.disarmPointer\(\)/.test(menuQml), 'menu route changes only accept an initial pointer sample for mouse activation' ) assert(