mirror of https://github.com/zulip/zulip.git
popovers: Add keyboard support for topic popovers in left sidebar.
This commit adds arrow, vim_up/vim_down and enter hotkey support for navigating the popover menu.
This commit is contained in:
parent
2579781a0a
commit
5cef548708
|
@ -212,6 +212,7 @@ run_test("basic_chars", () => {
|
||||||
});
|
});
|
||||||
set_global("stream_popover", {
|
set_global("stream_popover", {
|
||||||
stream_popped: return_false,
|
stream_popped: return_false,
|
||||||
|
topic_popped: return_false,
|
||||||
});
|
});
|
||||||
set_global("emoji_picker", {
|
set_global("emoji_picker", {
|
||||||
reactions_popped: return_false,
|
reactions_popped: return_false,
|
||||||
|
|
|
@ -306,6 +306,11 @@ exports.process_enter_key = function (e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stream_popover.topic_popped()) {
|
||||||
|
stream_popover.topic_sidebar_menu_handle_keyboard("enter");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (overlays.settings_open()) {
|
if (overlays.settings_open()) {
|
||||||
// On the settings page just let the browser handle
|
// On the settings page just let the browser handle
|
||||||
// the Enter key for things like submitting forms.
|
// the Enter key for things like submitting forms.
|
||||||
|
@ -563,6 +568,11 @@ exports.process_hotkey = function (e, hotkey) {
|
||||||
stream_popover.stream_sidebar_menu_handle_keyboard(event_name);
|
stream_popover.stream_sidebar_menu_handle_keyboard(event_name);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stream_popover.topic_popped()) {
|
||||||
|
stream_popover.topic_sidebar_menu_handle_keyboard(event_name);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The next two sections date back to 00445c84 and are Mac/Chrome-specific,
|
// The next two sections date back to 00445c84 and are Mac/Chrome-specific,
|
||||||
|
|
|
@ -34,6 +34,11 @@ exports.stream_sidebar_menu_handle_keyboard = (key) => {
|
||||||
popovers.popover_items_handle_keyboard(key, items);
|
popovers.popover_items_handle_keyboard(key, items);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.topic_sidebar_menu_handle_keyboard = (key) => {
|
||||||
|
const items = get_popover_menu_items(current_topic_sidebar_elem);
|
||||||
|
popovers.popover_items_handle_keyboard(key, items);
|
||||||
|
};
|
||||||
|
|
||||||
function elem_to_stream_id(elem) {
|
function elem_to_stream_id(elem) {
|
||||||
const stream_id = parseInt(elem.attr("data-stream-id"), 10);
|
const stream_id = parseInt(elem.attr("data-stream-id"), 10);
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,9 @@
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
{{! tabindex="0" Makes anchor tag focusable. Needed for keyboard support. }}
|
||||||
<li>
|
<li>
|
||||||
<a class="narrow_to_topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
<a tabindex="0" class="narrow_to_topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||||
<i class="fa fa-bullhorn" aria-hidden="true"></i>
|
<i class="fa fa-bullhorn" aria-hidden="true"></i>
|
||||||
{{t "Narrow to topic"}}
|
{{t "Narrow to topic"}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
|
|
||||||
{{#if can_mute_topic}}
|
{{#if can_mute_topic}}
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="sidebar-popover-mute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
<a tabindex="0" class="sidebar-popover-mute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||||
<i class="fa fa-bell-slash" aria-hidden="true"></i>
|
<i class="fa fa-bell-slash" aria-hidden="true"></i>
|
||||||
{{t "Mute topic"}}
|
{{t "Mute topic"}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -27,14 +28,14 @@
|
||||||
|
|
||||||
{{#if can_unmute_topic}}
|
{{#if can_unmute_topic}}
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="sidebar-popover-unmute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
<a tabindex="0" class="sidebar-popover-unmute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||||
<i class="fa fa-bell" aria-hidden="true"></i>
|
<i class="fa fa-bell" aria-hidden="true"></i>
|
||||||
{{t "Unmute topic"}}
|
{{t "Unmute topic"}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<li>
|
<li>
|
||||||
<a class="sidebar-popover-mark-topic-read" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
<a tabindex="0" class="sidebar-popover-mark-topic-read" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||||
<i class="fa fa-book" aria-hidden="true"></i>
|
<i class="fa fa-book" aria-hidden="true"></i>
|
||||||
{{t "Mark all messages as read"}}
|
{{t "Mark all messages as read"}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -45,7 +46,7 @@
|
||||||
<div class="admin-separator">{{#tr this}}ADMIN ACTIONS{{/tr}}</div>
|
<div class="admin-separator">{{#tr this}}ADMIN ACTIONS{{/tr}}</div>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a class="sidebar-popover-delete-topic-messages" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
<a tabindex="0" class="sidebar-popover-delete-topic-messages" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||||
<i class="fa fa-trash" aria-hidden="true"></i>
|
<i class="fa fa-trash" aria-hidden="true"></i>
|
||||||
{{t "Delete all messages in topic"}}
|
{{t "Delete all messages in topic"}}
|
||||||
</a>
|
</a>
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
|
|
||||||
{{#if is_admin}}
|
{{#if is_admin}}
|
||||||
<li>
|
<li>
|
||||||
<a class="sidebar-popover-move-topic-messages" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
<a tabindex="0" class="sidebar-popover-move-topic-messages" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
|
||||||
<i class="fa fa-arrows" aria-hidden="true"></i>
|
<i class="fa fa-arrows" aria-hidden="true"></i>
|
||||||
{{t "Move topic"}}
|
{{t "Move topic"}}
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue