mirror of
https://github.com/zulip/zulip.git
synced 2025-11-21 15:09:34 +00:00
modals: Rename is_open to any_active.
This commit is contained in:
@@ -280,7 +280,7 @@ export function process_escape_key(e) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modals.is_open()) {
|
if (modals.any_active()) {
|
||||||
modals.close_active();
|
modals.close_active();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -486,7 +486,7 @@ export function process_enter_key(e) {
|
|||||||
|
|
||||||
// All custom logic for overlays/modals is above; if we're in a
|
// All custom logic for overlays/modals is above; if we're in a
|
||||||
// modal at this point, let the browser handle the event.
|
// modal at this point, let the browser handle the event.
|
||||||
if (modals.is_open()) {
|
if (modals.any_active()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -695,7 +695,7 @@ export function process_hotkey(e, hotkey) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// `list_util` will process the event in send later modal.
|
// `list_util` will process the event in send later modal.
|
||||||
if (modals.is_open() && modals.active_modal() !== "#send_later_modal") {
|
if (modals.any_active() && modals.active_modal() !== "#send_later_modal") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ function call_hooks(func_list: Hook[]): void {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function is_open(): boolean {
|
export function any_active(): boolean {
|
||||||
return $(".micromodal").hasClass("modal--open");
|
return $(".micromodal").hasClass("modal--open");
|
||||||
}
|
}
|
||||||
|
|
||||||
export function active_modal(): string | undefined {
|
export function active_modal(): string | undefined {
|
||||||
if (!is_open()) {
|
if (!any_active()) {
|
||||||
blueslip.error("Programming error — Called active_modal when there is no modal open");
|
blueslip.error("Programming error — Called active_modal when there is no modal open");
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -68,10 +68,10 @@ export function open(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_open()) {
|
if (any_active()) {
|
||||||
/*
|
/*
|
||||||
Our modal system doesn't directly support opening a modal
|
Our modal system doesn't directly support opening a modal
|
||||||
when one is already open, because the `is_open` CSS
|
when one is already open, because the `any_active` CSS
|
||||||
class doesn't update until Micromodal has finished its
|
class doesn't update until Micromodal has finished its
|
||||||
animations, which can take 100ms or more.
|
animations, which can take 100ms or more.
|
||||||
|
|
||||||
@@ -178,8 +178,8 @@ export function close(modal_id: string, conf: Pick<ModalConfig, "on_hidden"> = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_open()) {
|
if (!any_active()) {
|
||||||
blueslip.warn("close_active() called without checking is_open()");
|
blueslip.warn("close_active() called without checking any_active()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ export function close_if_open(modal_id: string): void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_open()) {
|
if (!any_active()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,8 +229,8 @@ export function close_if_open(modal_id: string): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function close_active(): void {
|
export function close_active(): void {
|
||||||
if (!is_open()) {
|
if (!any_active()) {
|
||||||
blueslip.warn("close_active() called without checking is_open()");
|
blueslip.warn("close_active() called without checking any_active()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ import * as modals from "./modals";
|
|||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
|
|
||||||
export function any_active(): boolean {
|
export function any_active(): boolean {
|
||||||
return overlays.is_active() || modals.is_open();
|
return overlays.is_active() || modals.any_active();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export let settings_label;
|
|||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
$("#settings_overlay_container").on("click", (e) => {
|
$("#settings_overlay_container").on("click", (e) => {
|
||||||
if (!modals.is_open()) {
|
if (!modals.any_active()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($(e.target).closest(".micromodal").length > 0) {
|
if ($(e.target).closest(".micromodal").length > 0) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ function compare_by_name(a, b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function get_user_id_if_user_profile_modal_open() {
|
export function get_user_id_if_user_profile_modal_open() {
|
||||||
if (modals.is_open() && modals.active_modal() === "#user-profile-modal") {
|
if (modals.any_active() && modals.active_modal() === "#user-profile-modal") {
|
||||||
const user_id = $("#user-profile-modal").data("user-id");
|
const user_id = $("#user-profile-modal").data("user-id");
|
||||||
return user_id;
|
return user_id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ const narrow_state = mock_esm("../src/narrow_state", {
|
|||||||
});
|
});
|
||||||
const navigate = mock_esm("../src/navigate");
|
const navigate = mock_esm("../src/navigate");
|
||||||
const modals = mock_esm("../src/modals", {
|
const modals = mock_esm("../src/modals", {
|
||||||
is_open: () => false,
|
any_active: () => false,
|
||||||
active_modal: () => undefined,
|
active_modal: () => undefined,
|
||||||
});
|
});
|
||||||
const overlays = mock_esm("../src/overlays", {
|
const overlays = mock_esm("../src/overlays", {
|
||||||
@@ -350,7 +350,7 @@ run_test("drafts closed launch", ({override}) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
run_test("modal open", ({override}) => {
|
run_test("modal open", ({override}) => {
|
||||||
override(modals, "is_open", () => true);
|
override(modals, "any_active", () => true);
|
||||||
test_normal_typing();
|
test_normal_typing();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user