Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
modal: Add keyboard navigation for stream/group list scroll container.
Pratik Chandadc0b0462d553
diff --git a/web/src/user_profile.ts b/web/src/user_profile.tsindex 3c444e5df4f..69d8e9c9aa5 100644--- a/web/src/user_profile.ts+++ b/web/src/user_profile.ts@@ -1684,14 +1684,120 @@ export function initialize(): void {$("body").on("keydown",- ".stream-list-container .view-stream-card, .group-list-container .view_user_group",+ ".stream-list-container .stream-search, .group-list-container .group-search",function (this: HTMLElement, e) {- if (e.key !== "Enter") {- return;+ const $container = $(this).closest(".stream-list-container, .group-list-container");+ if (e.key === "ArrowDown") {+ e.preventDefault();+ e.stopPropagation();+ $container.find(".modal-item-list .list-row-content").first().trigger("focus");+ } else if (e.key === "ArrowUp") {+ e.preventDefault();+ e.stopPropagation();+ $container.find(".modal-item-list .list-row-content").last().trigger("focus");+ }+ },+ );++ $("body").on("keydown", ".modal-item-list .list-row-content", function (this: HTMLElement, e) {+ const $row = $(this).closest(".modal-list-item");+ switch (e.key) {+ case "Enter": {+ e.preventDefault();+ e.stopPropagation();+ $(this).trigger("click");+ break;+ }+ case "ArrowLeft":+ case "ArrowRight": {+ const $remove_button = $row.find(".hidden-remove-button");+ if ($remove_button.length === 0) {+ return;+ }+ e.preventDefault();+ e.stopPropagation();+ $remove_button.trigger("focus");+ break;+ }+ case "ArrowDown": {+ e.preventDefault();+ e.stopPropagation();+ const $next_item = $row.next(".modal-list-item");+ if ($next_item.length > 0) {+ $next_item.find(".list-row-content").trigger("focus");+ } else {+ $(this)+ .closest(".stream-list-container, .group-list-container")+ .find(".stream-search, .group-search")+ .trigger("focus");+ }+ break;+ }+ case "ArrowUp": {+ e.preventDefault();+ e.stopPropagation();+ const $prev_item = $row.prev(".modal-list-item");+ if ($prev_item.length > 0) {+ $prev_item.find(".list-row-content").trigger("focus");+ } else {+ $(this)+ .closest(".stream-list-container, .group-list-container")+ .find(".stream-search, .group-search")+ .trigger("focus");+ }+ break;+ }+ }+ });++ $("body").on(+ "keydown",+ ".modal-item-list .hidden-remove-button",+ function (this: HTMLElement, e) {+ const $row = $(this).closest(".modal-list-item");+ switch (e.key) {+ case "ArrowLeft":+ case "ArrowRight": {+ e.preventDefault();+ e.stopPropagation();+ $row.find(".list-row-content").trigger("focus");+ break;+ }+ case "ArrowDown": {+ e.preventDefault();+ e.stopPropagation();+ const $next_item = $row.next(".modal-list-item");+ const $next_button = $next_item.find(".hidden-remove-button");+ if ($next_item.length > 0 && $next_button.length > 0) {+ $next_button.trigger("focus");+ } else {+ $(this)+ .closest(".stream-list-container, .group-list-container")+ .find(".stream-search, .group-search")+ .trigger("focus");+ }+ break;+ }+ case "ArrowUp": {+ e.preventDefault();+ e.stopPropagation();+ const $prev_item = $row.prev(".modal-list-item");+ if ($prev_item.length > 0) {+ const $prev_button = $prev_item.find(".hidden-remove-button");+ if ($prev_button.length > 0) {+ $prev_button.trigger("focus");+ } else {+ $prev_item.find(".list-row-content").trigger("focus");+ }+ } else {+ $(this)+ .closest(".stream-list-container, .group-list-container")+ .find(".stream-search, .group-search")+ .trigger("focus");+ }+ break;+ }}- e.preventDefault();- e.stopPropagation();- $(this).trigger("click");},);diff --git a/web/styles/popovers.css b/web/styles/popovers.cssindex 91cdfa0c135..56df860f612 100644--- a/web/styles/popovers.css+++ b/web/styles/popovers.css@@ -246,6 +246,8 @@}.hidden-remove-button-row:hover+ .hidden-remove-button:not(:has(.button-loading-indicator)),+.hidden-remove-button-row:focus-within.hidden-remove-button:not(:has(.button-loading-indicator)) {opacity: 1;pointer-events: auto;