views: Set focus to topic visibility icon on click.

This commit is contained in:
Aman Agrawal 2024-06-21 10:08:36 +00:00 committed by Tim Abbott
parent dd071c7303
commit 1c3c794385
3 changed files with 16 additions and 1 deletions

View File

@ -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();

View File

@ -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",

View File

@ -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).
},
});
}