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.

popovers: Add keyboard support for user popovers in right sidebar.

Mohit Gupta98da8cd7f2fd
diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js
index b6f92f664ef..0be4280ac1b 100644
--- a/frontend_tests/node_tests/hotkey.js
+++ b/frontend_tests/node_tests/hotkey.js
@@ -209,6 +209,7 @@ run_test("basic_chars", () => {
set_global("popovers", {
actions_popped: return_false,
message_info_popped: return_false,
+ user_sidebar_popped: return_false,
});
set_global("stream_popover", {
stream_popped: return_false,
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index ea6f7d669d7..6a28bf73c1b 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -301,6 +301,11 @@ exports.process_enter_key = function (e) {
return true;
}
+ if (popovers.user_sidebar_popped()) {
+ popovers.user_sidebar_popover_handle_keyboard("enter");
+ return true;
+ }
+
if (stream_popover.stream_popped()) {
stream_popover.stream_sidebar_menu_handle_keyboard("enter");
return true;
@@ -574,6 +579,11 @@ exports.process_hotkey = function (e, hotkey) {
return true;
}
+ if (popovers.user_sidebar_popped()) {
+ popovers.user_sidebar_popover_handle_keyboard(event_name);
+ return true;
+ }
+
if (stream_popover.stream_popped()) {
stream_popover.stream_sidebar_menu_handle_keyboard(event_name);
return true;
diff --git a/static/js/popovers.js b/static/js/popovers.js
index ddc24d6e838..2cd45aed791 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -690,6 +690,20 @@ function focus_user_info_popover_item() {
exports.focus_first_popover_item(items);
}
+function get_user_sidebar_popover_items() {
+ if (!current_user_sidebar_popover) {
+ blueslip.error("Trying to get menu items when user sidebar popover is closed.");
+ return;
+ }
+
+ return $("li:not(.divider):visible > a", current_user_sidebar_popover.$tip);
+}
+
+exports.user_sidebar_popover_handle_keyboard = function (key) {
+ const items = get_user_sidebar_popover_items();
+ exports.popover_items_handle_keyboard(key, items);
+};
+
exports.user_info_popover_handle_keyboard = function (key) {
const items = get_user_info_popover_items();
exports.popover_items_handle_keyboard(key, items);