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
This commit is contained in:
Ganesh Pawar 2021-06-06 22:58:12 +05:30 committed by Tim Abbott
parent 9032d43408
commit 2965fec355
1 changed files with 4 additions and 0 deletions

View File

@ -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