popovers: Fix bug where modals persisted on hashchange.

Modals like those for Read receipts, Schedule message, Message edit
history, User profile, etc would not close when the hash changed.

Now we close any active modal whenever the hash changes; we add a new
function in `modals.ts` to do this, and call it from `hashchange.js`.
This commit is contained in:
N-Shar-ma 2023-10-23 01:28:33 +05:30 committed by Tim Abbott
parent 3f2ab44f94
commit 82f105aada
2 changed files with 8 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import * as info_overlay from "./info_overlay";
import * as message_lists from "./message_lists";
import * as message_scroll from "./message_scroll";
import * as message_viewport from "./message_viewport";
import * as modals from "./modals";
import * as narrow from "./narrow";
import * as overlays from "./overlays";
import {page_params} from "./page_params";
@ -407,6 +408,7 @@ function hashchanged(from_reload, e) {
overlays.close_for_hash_change();
sidebar_ui.hide_all();
popovers.hide_all();
modals.close_active_if_any();
browser_history.state.changing_hash = true;
const ret = do_hashchange_normal(from_reload);
browser_history.state.changing_hash = false;

View File

@ -237,3 +237,9 @@ export function close_active(): void {
const $micromodal = $(".micromodal.modal--open");
Micromodal.close(`${CSS.escape($micromodal.attr("id") ?? "")}`);
}
export function close_active_if_any(): void {
if (any_active()) {
close_active();
}
}