diff --git a/web/src/dialog_widget.js b/web/src/dialog_widget.js index 7b74bd403a..f60d111c1c 100644 --- a/web/src/dialog_widget.js +++ b/web/src/dialog_widget.js @@ -117,10 +117,6 @@ export function launch(conf) { } const $submit_button = $dialog.find(".dialog_submit_button"); - const $send_email_checkbox = $dialog.find(".send_email"); - const $email_field = $dialog.find(".email_field"); - - $email_field.hide(); // This is used to link the submit button with the form, if present, in the modal. // This makes it so that submitting this form by pressing Enter on an input element @@ -143,14 +139,6 @@ export function launch(conf) { conf.on_click(e); }); - $send_email_checkbox.on("change", () => { - if ($send_email_checkbox.is(":checked")) { - $email_field.show(); - } else { - $email_field.hide(); - } - }); - overlays.open_modal("dialog_widget_modal", { autoremove: true, on_show() { diff --git a/web/src/settings_users.js b/web/src/settings_users.js index 01332c750a..700645b523 100644 --- a/web/src/settings_users.js +++ b/web/src/settings_users.js @@ -483,6 +483,20 @@ export function confirm_deactivation(user_id, handle_confirm, loading_spinner) { }; const html_body = render_settings_deactivation_user_modal(opts); + function set_email_field_visibility() { + const $send_email_checkbox = $("#dialog_widget_modal").find(".send_email"); + const $email_field = $("#dialog_widget_modal").find(".email_field"); + + $email_field.hide(); + $send_email_checkbox.on("change", () => { + if ($send_email_checkbox.is(":checked")) { + $email_field.show(); + } else { + $email_field.hide(); + } + }); + } + dialog_widget.launch({ html_heading: $t_html( {defaultMessage: "Deactivate {name}?"}, @@ -493,6 +507,7 @@ export function confirm_deactivation(user_id, handle_confirm, loading_spinner) { html_submit_button: $t_html({defaultMessage: "Deactivate"}), id: "deactivate-user-modal", on_click: handle_confirm, + post_render: set_email_field_visibility, loading_spinner, }); },