popovers: Hide when starting certain actions.

These are actions which can be called when a popover is open and
it is better to close the popover when these actions are
initiated.
This commit is contained in:
Aman Agrawal 2023-10-23 02:23:05 +00:00 committed by Tim Abbott
parent c9891b4121
commit a210006ecd
6 changed files with 16 additions and 2 deletions

View File

@ -210,6 +210,7 @@ export function set_cursor_and_filter() {
export function initiate_search() { export function initiate_search() {
if (user_filter) { if (user_filter) {
popovers.hide_all();
user_filter.initiate_search(); user_filter.initiate_search();
} }
} }

View File

@ -17,6 +17,7 @@ import * as message_viewport from "./message_viewport";
import * as narrow_state from "./narrow_state"; import * as narrow_state from "./narrow_state";
import {page_params} from "./page_params"; import {page_params} from "./page_params";
import * as people from "./people"; import * as people from "./people";
import * as popovers from "./popovers";
import * as reload_state from "./reload_state"; import * as reload_state from "./reload_state";
import * as resize from "./resize"; import * as resize from "./resize";
import * as settings_config from "./settings_config"; import * as settings_config from "./settings_config";
@ -191,6 +192,7 @@ export function start(msg_type, opts) {
blueslip.warn("Empty message type in compose.start"); blueslip.warn("Empty message type in compose.start");
} }
popovers.hide_all();
autosize_message_content(); autosize_message_content();
if (reload_state.is_in_progress()) { if (reload_state.is_in_progress()) {

View File

@ -238,6 +238,7 @@ export function open_search_bar_and_close_narrow_description() {
} }
$(".navbar-search").addClass("expanded"); $(".navbar-search").addClass("expanded");
$("#message_view_header").addClass("hidden"); $("#message_view_header").addClass("hidden");
popovers.hide_all();
} }
export function close_search_bar_and_open_narrow_description() { export function close_search_bar_and_open_narrow_description() {

View File

@ -907,6 +907,7 @@ export function hide_search_section() {
} }
export function initiate_search() { export function initiate_search() {
popovers.hide_all();
show_search_section(); show_search_section();
const $filter = $(".stream-list-filter").expectOne(); const $filter = $(".stream-list-filter").expectOne();

View File

@ -58,6 +58,9 @@ mock_esm("../src/message_lists", {
mock_esm("../src/resize", { mock_esm("../src/resize", {
reset_compose_message_max_height: noop, reset_compose_message_max_height: noop,
}); });
mock_esm("../src/popovers", {
hide_all: noop,
});
const people = zrequire("people"); const people = zrequire("people");

View File

@ -17,7 +17,9 @@ mock_esm("../src/resize", {
resize_stream_filters_container: noop, resize_stream_filters_container: noop,
}); });
const popovers = mock_esm("../src/popovers"); const popovers = mock_esm("../src/popovers", {
hide_all: noop,
});
const sidebar_ui = mock_esm("../src/sidebar_ui"); const sidebar_ui = mock_esm("../src/sidebar_ui");
const stream_list = zrequire("stream_list"); const stream_list = zrequire("stream_list");
@ -188,5 +190,9 @@ run_test("expanding_sidebar", () => {
stream_list.initiate_search(); stream_list.initiate_search();
assert.deepEqual(events, ["popovers.hide_all", "sidebar_ui.show_streamlist_sidebar"]); assert.deepEqual(events, [
"popovers.hide_all",
"popovers.hide_all",
"sidebar_ui.show_streamlist_sidebar",
]);
}); });