Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions shell/plugins/menu/Menu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,17 @@ 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) {
// 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 = ""
root.selectedIndex = 0
root.selectedIndex = restoreIndex !== undefined ? restoreIndex : 0
root.cursorActive = true
if (fromPointer) pointerGate.allowInitialSample()
else root.disarmPointer()
Expand All @@ -747,7 +751,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
}

Expand Down
2 changes: 1 addition & 1 deletion test/shell.d/menu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Cursor restoration lacks test coverage

The updated assertion only checks the new setActiveMenu signature and pointer behavior. It would still pass if goBack stopped restoring previous.index. Add regression checks for saving and restoring a nonzero index, nested Back navigation, and returning to index 0 after leaving a filtered menu.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

'menu route changes only accept an initial pointer sample for mouse activation'
)
assert(
Expand Down