Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

popover_menus: Allow focusing an item when none is focused.

Anders Kaseorg7eec8fe3a22e
diff --git a/web/src/popover_menus.ts b/web/src/popover_menus.ts
index 8dae6009add..5671024a059 100644
--- a/web/src/popover_menus.ts
+++ b/web/src/popover_menus.ts
@@ -77,14 +77,14 @@ export function popover_items_handle_keyboard(key: string, $items?: JQuery): voi
return;
}
- if ((key === "down_arrow" || key === "vim_down") && index !== -1) {
+ if (key === "down_arrow" || key === "vim_down") {
[...$items]
- .slice(index + 1)
+ .slice(index === -1 ? 0 : index + 1)
.find((item) => item.getClientRects().length)
?.focus();
- } else if ((key === "up_arrow" || key === "vim_up") && index !== -1) {
+ } else if (key === "up_arrow" || key === "vim_up") {
[...$items]
- .slice(0, index)
+ .slice(0, index === -1 ? $items.length : index)
.findLast((item) => item.getClientRects().length)
?.focus();
}