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.

right_sidebar: Allow keyboard navigation to toggle user lists.

Evy Kassirer1779e0e70ad6
diff --git a/web/src/left_sidebar_tooltips.ts b/web/src/left_sidebar_tooltips.ts
index 964b85eb48a..b5aed98d3e4 100644
--- a/web/src/left_sidebar_tooltips.ts
+++ b/web/src/left_sidebar_tooltips.ts
@@ -239,6 +239,28 @@ export function initialize(): void {
},
});
+ // This is actually for the right sidebar, but putting it here because it has
+ // shared logic.
+ tippy.delegate("body", {
+ target: ".section-toggle-tooltip-target",
+ onShow(instance) {
+ const $toggle = $(instance.reference);
+ observe_toggle_class(instance, () => {
+ if ($toggle.hasClass("rotate-icon-down")) {
+ instance.setContent($t({defaultMessage: "Collapse section"}));
+ } else {
+ instance.setContent($t({defaultMessage: "Expand section"}));
+ }
+ });
+ },
+ delay: EXTRA_LONG_HOVER_DELAY,
+ appendTo: () => document.body,
+ onHidden(instance) {
+ disconnect_toggle_class(instance);
+ instance.destroy();
+ },
+ });
+
tippy.delegate("body", {
target: ".header-main .column-left .left-sidebar-toggle-button",
delay: LONG_HOVER_DELAY,
diff --git a/web/src/sidebar_ui.ts b/web/src/sidebar_ui.ts
index 05e38ea00d6..5264c0aca3f 100644
--- a/web/src/sidebar_ui.ts
+++ b/web/src/sidebar_ui.ts
@@ -401,16 +401,41 @@ export function initialize_right_sidebar(): void {
},
);
+ $("#buddy-list-users-matching-view-container").on(
+ "keydown",
+ ".buddy-list-section-toggle",
+ (e) => {
+ if (keydown_util.is_enter_event(e)) {
+ e.stopPropagation();
+ buddy_list.toggle_users_matching_view_section();
+ }
+ },
+ );
+
$("#buddy-list-participants-container").on("click", ".buddy-list-subsection-header", (e) => {
e.stopPropagation();
buddy_list.toggle_participants_section();
});
+ $("#buddy-list-participants-container").on("keydown", ".buddy-list-section-toggle", (e) => {
+ if (keydown_util.is_enter_event(e)) {
+ e.stopPropagation();
+ buddy_list.toggle_participants_section();
+ }
+ });
+
$("#buddy-list-other-users-container").on("click", ".buddy-list-subsection-header", (e) => {
e.stopPropagation();
buddy_list.toggle_other_users_section();
});
+ $("#buddy-list-other-users-container").on("keydown", ".buddy-list-section-toggle", (e) => {
+ if (keydown_util.is_enter_event(e)) {
+ e.stopPropagation();
+ buddy_list.toggle_other_users_section();
+ }
+ });
+
function close_buddy_list_popover(): void {
if (popover_menus.popover_instances.buddy_list !== null) {
popover_menus.popover_instances.buddy_list.destroy();
diff --git a/web/styles/right_sidebar.css b/web/styles/right_sidebar.css
index 1f543c2a245..1317947e18c 100644
--- a/web/styles/right_sidebar.css
+++ b/web/styles/right_sidebar.css
@@ -46,6 +46,14 @@
justify-self: center;
color: var(--color-text-sidebar-heading);
opacity: var(--opacity-sidebar-heading-icon);
+
+ &:focus {
+ outline: 0;
+ }
+
+ &:focus-visible {
+ outline: 2px solid var(--color-outline-focus);
+ }
}
.buddy-list-section-container {
diff --git a/web/templates/buddy_list/section_header.hbs b/web/templates/buddy_list/section_header.hbs
index 891259976df..8ed31b73005 100644
--- a/web/templates/buddy_list/section_header.hbs
+++ b/web/templates/buddy_list/section_header.hbs
@@ -1,4 +1,4 @@
-<i class="buddy-list-section-toggle zulip-icon zulip-icon-heading-triangle-right {{#if is_collapsed}}rotate-icon-right{{else}}rotate-icon-down{{/if}}" aria-hidden="true"></i>
+<i class="buddy-list-section-toggle section-toggle-tooltip-target zulip-icon zulip-icon-heading-triangle-right {{#if is_collapsed}}rotate-icon-right{{else}}rotate-icon-down{{/if}}" tabindex="0" role="button"></i>
<h5 id="{{id}}" class="buddy-list-heading no-style hidden-for-spectators">
<span class="buddy-list-heading-text">{{header_text}}</span>
{{!-- Hide the count until we have fetched data to display the correct count --}}