hotkey: Focus visible input filter field on query streams hotkey.

Earlier, if pm_list or stream_list was zoomed in and hitting `q`
hotkey would seemingly do nothing but in the background would add
highlighted class to `stream_row` and toggle stream-list-filter.

This commit fixes this behaviour by bringing focus to currently
visible input filter field.
This commit is contained in:
Pratik Chanda
2025-01-31 17:39:49 +05:30
committed by Tim Abbott
parent c071d952e1
commit 2a26f34983
4 changed files with 28 additions and 2 deletions

View File

@@ -7,8 +7,10 @@ import {localstorage} from "./localstorage.ts";
import * as pm_list_data from "./pm_list_data.ts";
import * as pm_list_dom from "./pm_list_dom.ts";
import type {PMNode} from "./pm_list_dom.ts";
import * as popovers from "./popovers.ts";
import * as resize from "./resize.ts";
import * as scroll_util from "./scroll_util.ts";
import * as sidebar_ui from "./sidebar_ui.ts";
import * as ui_util from "./ui_util.ts";
import type {FullUnreadCountsData} from "./unread.ts";
import * as vdom from "./vdom.ts";
@@ -31,6 +33,13 @@ export function is_zoomed_in(): boolean {
return zoomed;
}
export function focus_pm_search_filter(): void {
popovers.hide_all();
sidebar_ui.show_left_sidebar();
const $filter = $(".direct-messages-list-filter").expectOne();
$filter.trigger("focus");
}
function get_private_messages_section_header(): JQuery {
return $("#direct-messages-section-header");
}