From 1c3c794385a877482ad71aaaa1f9ae0f71b50517 Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Fri, 21 Jun 2024 10:08:36 +0000 Subject: [PATCH] views: Set focus to topic visibility icon on click. --- web/src/inbox_ui.ts | 8 +++++++- web/src/recent_view_ui.ts | 5 +++++ web/src/user_topic_popover.js | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web/src/inbox_ui.ts b/web/src/inbox_ui.ts index 001438e602..97a33e0511 100644 --- a/web/src/inbox_ui.ts +++ b/web/src/inbox_ui.ts @@ -825,7 +825,7 @@ function focus_clicked_list_element($elt: JQuery): void { update_triggered_by_user = true; } -function revive_current_focus(): void { +export function revive_current_focus(): void { if (is_list_focused()) { set_list_focus(); } else { @@ -1553,6 +1553,12 @@ export function initialize(): void { } }); + $("body").on("click", "#inbox-list .change_visibility_policy", function (this: HTMLElement) { + const $elt = $(this); + col_focus = COLUMNS.TOPIC_VISIBILITY; + focus_clicked_list_element($elt); + }); + $("body").on("click", "#inbox-clear-search", () => { $("#inbox-search").val(""); search_and_update(); diff --git a/web/src/recent_view_ui.ts b/web/src/recent_view_ui.ts index e5ebd75c4e..57811f1a15 100644 --- a/web/src/recent_view_ui.ts +++ b/web/src/recent_view_ui.ts @@ -1836,6 +1836,11 @@ export function initialize({ window.location.href = $(e.currentTarget).find("a").attr("href")!; }); + $("body").on("click", "#recent-view-content-table .change_visibility_policy", (e) => { + const topic_row_index = $(e.target).closest("tr").index(); + focus_clicked_element(topic_row_index, COLUMNS.mute); + }); + // Search for all table rows (this combines stream & topic names) $("body").on( "keyup", diff --git a/web/src/user_topic_popover.js b/web/src/user_topic_popover.js index b2a53d00fe..bd608834f1 100644 --- a/web/src/user_topic_popover.js +++ b/web/src/user_topic_popover.js @@ -102,6 +102,10 @@ export function initialize() { .removeClass("visibility-policy-popover-visible"); instance.destroy(); popover_menus.popover_instances.change_visibility_policy = undefined; + + // If the reference is in recent view / inbox, we would ideally restore focus + // to the reference icon here but we don't do that because there are a lot of + // reasons why the popover might be hidden (e.g. user clicking outside the popover). }, }); }