Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
modal: Don't close modal on Escape key if any popover is open.
Pratik Chanda70f1c315b987
diff --git a/web/src/modals.ts b/web/src/modals.tsindex 9300fa60551..c166f73c665 100644--- a/web/src/modals.ts+++ b/web/src/modals.ts@@ -6,6 +6,7 @@ import * as blueslip from "./blueslip.ts";import * as mouse_drag from "./mouse_drag.ts";import * as overlay_util from "./overlay_util.ts";import * as overlays from "./overlays.ts";+import * as popovers from "./popovers.ts";type Hook = () => void;@@ -144,6 +145,18 @@ export function open(}});+ // Micromodal registers a document-level keydown handler that closes+ // the modal on Escape. When a popover is open inside the modal,+ // Escape should close just the popover, not the modal behind it.+ // We intercept the event here so that Micromodal's handler never+ // sees it when a popover is active.+ $micromodal.on("keydown", (e) => {+ if (e.key === "Escape" && popovers.any_active()) {+ popovers.hide_all();+ e.stopPropagation();+ }+ });+$micromodal.find(".modal__overlay").on("click", (e) => {if (!$(e.target).is(".modal__overlay")) {return;