modals: Do not remove modal element from DOM after closing the modal.

This commit changes the code to not remove the modal element from DOM
after closing the modal for the deactivation stream modal and stream
privacy modal.

This is a prep commit for enabling background mouse events
unconditionally using 'hidden.bs.modal', because removing element
using '.remove' remove all events attached to it and this will also
remove the 'hidden.bs.modal' event which we do not want.

This remove behavior is inconsistent as we remove some of the modals
but do not remove some, so for now we are not removing the modal
after closing but it is anyway removed before opening a modal to handle
case of having two elements of same id and avoids any bugs.
This behavior of when to remove the element from DOM and when to not
remove needs to be discussed and may be modified in future.
This commit is contained in:
sahil839
2020-08-10 02:16:21 +05:30
committed by Tim Abbott
parent 677ba4bc25
commit 7489213768

View File

@@ -587,7 +587,6 @@ function change_stream_privacy(e) {
if (Object.keys(data).length === 0) {
overlays.close_modal("#stream_privacy_modal");
$("#stream_privacy_modal").remove();
return;
}
@@ -596,7 +595,6 @@ function change_stream_privacy(e) {
data,
success() {
overlays.close_modal("#stream_privacy_modal");
$("#stream_privacy_modal").remove();
// The rest will be done by update stream event we will get.
},
error(xhr) {
@@ -882,7 +880,6 @@ export function initialize() {
$("#subscriptions_table").on("click", "#do_deactivate_stream_button", (e) => {
const stream_id = $(e.target).data("stream-id");
overlays.close_modal("#deactivation_stream_modal");
$("#deactivation_stream_modal").remove();
if (!stream_id) {
ui_report.client_error(i18n.t("Invalid stream id"), $(".stream_change_property_info"));
return;
@@ -891,10 +888,6 @@ export function initialize() {
delete_stream(stream_id, $(".stream_change_property_info"), row);
});
$("#subscriptions_table").on("hide.bs.modal", "#deactivation_stream_modal", () => {
$("#deactivation_stream_modal").remove();
});
$("#subscriptions_table").on("click", ".stream-row", function (e) {
if ($(e.target).closest(".check, .subscription_settings").length === 0) {
open_edit_panel_for_row(this);