From 2965fec35551d77e88fbe15721cf1cbe2639c5d6 Mon Sep 17 00:00:00 2001 From: Ganesh Pawar Date: Sun, 6 Jun 2021 22:58:12 +0530 Subject: [PATCH] modals: Remove `in` class once modal is hidden. Rapidly clicking a button that shows a modal cause a race condition in Bootstrap. Specifically, Bootstrap adds an "in" class to a modal on the "shown" event and removes it on the "hide" event. Frequent clicks cause the "hide" event to trigger before the "shown" event. Therefore, the "in" class isn't removed. We use the "in" class to check if a modal is active in overlays.js For now, we manually remove it once the modal is hidden. Newer versions of Bootstrap probably handle this better internally. Look into removing this once it's upgraded. Fixes #15463 --- static/js/click_handlers.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js index 83452c7176..b545a37181 100644 --- a/static/js/click_handlers.js +++ b/static/js/click_handlers.js @@ -912,6 +912,10 @@ export function initialize() { $("body").on("hidden.bs.modal", () => { // Enable mouse events for the background as the modal closes. overlays.enable_background_mouse_events(); + + // TODO: Remove this once Bootstrap is upgraded. + // See: https://github.com/zulip/zulip/pull/18720 + $(".modal.in").removeClass("in"); }); // MAIN CLICK HANDLER