Focus the last menu item on ArrowUp

With nothing focused yet, ArrowUp landed on the second to last item.
This commit is contained in:
Rūdolfs Ošiņš
2026-10-01 18:20:25 +02:00
parent 08057ba962
commit f0d4d678aa
2 changed files with 2 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ export function menuFocusIndex(
case "ArrowDown":
return wrap(current + 1);
case "ArrowUp":
return wrap(current - 1);
return current === -1 ? count - 1 : wrap(current - 1);
case "Home":
return 0;
case "End":
+1
View File
@@ -6,6 +6,7 @@ test.each([
["ArrowDown", -1, 0],
["ArrowDown", 0, 1],
["ArrowDown", 2, 0],
["ArrowUp", -1, 2],
["ArrowUp", 0, 2],
["ArrowUp", 2, 1],
["Home", 1, 0],