Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
overlays: Keep drafts keyboard navigation on the selected draft.
Pritesh Shettyb69997290388
diff --git a/web/src/drafts_overlay_ui.ts b/web/src/drafts_overlay_ui.tsindex 91eefee0191..f049d85bcc2 100644--- a/web/src/drafts_overlay_ui.ts+++ b/web/src/drafts_overlay_ui.ts@@ -19,6 +19,7 @@ import {message_render_response_schema} from "./message_store.ts";import * as message_view from "./message_view.ts";import * as messages_overlay_ui from "./messages_overlay_ui.ts";import * as mouse_drag from "./mouse_drag.ts";+import * as overlay_util from "./overlay_util.ts";import * as overlays from "./overlays.ts";import * as people from "./people.ts";import {postprocess_content} from "./postprocess_content.ts";@@ -534,8 +535,37 @@ export function initialize(): void {});});- $("body").on("focus", "#drafts_table .overlay-message-info-box", function (this: HTMLElement) {- messages_overlay_ui.activate_element(this, keyboard_handling_context);+ $("body").on("focus", "#draft_overlay", (e) => {+ if (!(e.target instanceof HTMLElement)) {+ return;+ }+ const draft_row = e.target.closest(".overlay-message-info-box");+ if (draft_row instanceof HTMLElement) {+ // A draft gained focus; mark it as the selected draft.+ messages_overlay_ui.activate_element(draft_row, keyboard_handling_context);+ } else if (e.target.matches(overlay_util.OVERLAY_FOCUSABLE_SELECTOR)) {+ // Another focusable element (e.g. a header button) gained focus;+ // draft info-boxes are already handled by the branch above, so+ // the `.overlay-message-info-box` part of the selector never+ // matches here.+ // Only clear the draft selection when the control was reached via+ // keyboard (Tab), where both it and the draft would show a focus+ // ring; a pointer click shows no ring on the control, so keep the+ // selection.+ if (e.target.matches(":focus-visible")) {+ $("#drafts_table .overlay-message-info-box").removeClass("active");+ }+ } else {+ // Focus landed on a non-interactive area. Return focus to the+ // selected draft or the first one if none is selected, so that+ // keyboard navigation continues from a draft.+ const draft_to_focus =+ $("#drafts_table .overlay-message-info-box.active")[0] ??+ $("#drafts_table .overlay-message-info-box")[0];+ if (draft_to_focus !== undefined) {+ messages_overlay_ui.activate_element(draft_to_focus, keyboard_handling_context);+ }+ }});$("body").on("click",