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 All Messages popover in sidebar.

Mohit Guptaa1d3707bfb90
diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js
index f9b19596fa4..b550860b195 100644
--- a/frontend_tests/node_tests/hotkey.js
+++ b/frontend_tests/node_tests/hotkey.js
@@ -213,6 +213,7 @@ run_test("basic_chars", () => {
set_global("stream_popover", {
stream_popped: return_false,
topic_popped: return_false,
+ all_messages_popped: return_false,
});
set_global("emoji_picker", {
reactions_popped: return_false,
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index e5d5905e102..656329c6388 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -311,6 +311,11 @@ exports.process_enter_key = function (e) {
return true;
}
+ if (stream_popover.all_messages_popped()) {
+ stream_popover.all_messages_sidebar_menu_handle_keyboard("enter");
+ return true;
+ }
+
if (overlays.settings_open()) {
// On the settings page just let the browser handle
// the Enter key for things like submitting forms.
@@ -573,6 +578,11 @@ exports.process_hotkey = function (e, hotkey) {
stream_popover.topic_sidebar_menu_handle_keyboard(event_name);
return true;
}
+
+ if (stream_popover.all_messages_popped()) {
+ stream_popover.all_messages_sidebar_menu_handle_keyboard(event_name);
+ return true;
+ }
}
// The next two sections date back to 00445c84 and are Mac/Chrome-specific,
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index 9c71b5700da..04039cdd400 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -39,6 +39,11 @@ exports.topic_sidebar_menu_handle_keyboard = (key) => {
popovers.popover_items_handle_keyboard(key, items);
};
+exports.all_messages_sidebar_menu_handle_keyboard = (key) => {
+ const items = get_popover_menu_items(all_messages_sidebar_elem);
+ popovers.popover_items_handle_keyboard(key, items);
+};
+
function elem_to_stream_id(elem) {
const stream_id = parseInt(elem.attr("data-stream-id"), 10);
diff --git a/static/templates/all_messages_sidebar_actions.hbs b/static/templates/all_messages_sidebar_actions.hbs
index b48adbb0e6b..0e7b172d677 100644
--- a/static/templates/all_messages_sidebar_actions.hbs
+++ b/static/templates/all_messages_sidebar_actions.hbs
@@ -1,7 +1,8 @@
{{! Contents of the "all messages sidebar" popup }}
<ul class="nav nav-list">
<li>
- <a id="mark_all_messages_as_read">
+ {{! tabindex="0" Makes anchor tag focusable. Needed for keyboard support. }}
+ <a tabindex="0" id="mark_all_messages_as_read">
<i class="fa fa-book" aria-hidden="true"></i>
{{#tr this}}Mark all messages as read{{/tr}}
</a>