stream: Use 'hidden.bs.modal' event for enabling mouse background events.

We now unconditionally enable backgroung events when 'hidden.bs.modal'
event is triggered on closing of modal. We do not need to handle them
separateley for closing modal by close_modal, data-dismiss or escape.
We handle this by single handler for modals in settings and subscription
overlay.

Fixes #16688.
This commit is contained in:
sahil839
2020-08-10 03:04:22 +05:30
committed by Tim Abbott
parent 46db1da9a9
commit f73d101854
4 changed files with 5 additions and 27 deletions

View File

@@ -947,6 +947,11 @@ export function initialize() {
e.stopPropagation();
});
$("body").on("hidden.bs.modal", () => {
// Enable mouse events for the background as the modal closes.
overlays.enable_background_mouse_events();
});
// MAIN CLICK HANDLER
$(document).on("click", (e) => {
@@ -966,12 +971,6 @@ export function initialize() {
popovers.hide_all();
}
// If user clicks outside an active modal
if ($(".modal.in").has(e.target).length === 0) {
// Enable mouse events for the background as the modal closes
$(".overlay.show").attr("style", null);
}
if (compose_state.composing()) {
if ($(e.target).closest("a").length > 0) {
// Refocus compose message text box if link is clicked

View File

@@ -199,8 +199,6 @@ export function close_modal(selector) {
const elem = $(selector).expectOne();
elem.modal("hide").attr("aria-hidden", true);
// Enable mouse events for the background as the modal closes.
enable_background_mouse_events();
}
export function close_active_modal() {

View File

@@ -403,14 +403,6 @@ export function set_up() {
clear_password_change();
});
// If the modal is closed using the 'close' button or the 'Cancel' button
$(".modal")
.find("[data-dismiss=modal]")
.on("click", () => {
// Enable mouse events for the background on closing modal
$(".overlay.show").attr("style", null);
});
$("#change_password_button").on("click", (e) => {
e.preventDefault();
e.stopPropagation();

View File

@@ -746,17 +746,6 @@ export function initialize() {
$("#subscriptions_table").on("click", "#change-stream-privacy-button", change_stream_privacy);
$("#subscriptions_table").on("click", ".close-modal-btn", (e) => {
// Re-enable background mouse events when we close the modal
// via the "x" in the corner. (The other modal-close code
// paths call `overlays.close_modal`, rather than using
// bootstrap's data-dismiss=modal feature, and this is done
// there).
//
// TODO: It would probably be better to just do this
// unconditionally inside the handler for the event sent by
// bootstrap on closing a modal.
overlays.enable_background_mouse_events();
// This fixes a weird bug in which, subscription_settings hides
// unexpectedly by clicking the cancel button in a modal on top of it.
e.stopPropagation();