From 90205a490d8576f04c08471c28eb3c393317806b Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Tue, 21 Mar 2023 16:47:01 +0100 Subject: [PATCH] account-settings: Pass delivery email to change email modal. When we converted the change email form to a dialog widget modal, in commit f43d3b9986, the page_params value for delivery email that was being referenced in the handlebars template `change_email_modal.hbs` was not set, so instead an empty string was the initial input value. Because the email change dialog widget post_render callback sets the input value to the same delivery email, the fact that the email was not being set when the template was initially rendered was not noticable. Passes the page_params.delivery_email to the html parameter in dialog_widget.launch so that the template has the initial value set when the form is initially rendered. Removes the now redundant post_render callback, which resets the initial input value to the same delivery email. --- web/src/settings_account.js | 9 +-------- web/templates/change_email_modal.hbs | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/web/src/settings_account.js b/web/src/settings_account.js index a23cf3dd1e901..9104fe9a460ed 100644 --- a/web/src/settings_account.js +++ b/web/src/settings_account.js @@ -718,25 +718,18 @@ export function set_up() { ); } - function change_email_post_render() { - const $input_elem = $("#change_email_form").find("input[name='email']"); - const email = $("#change_email_button").text().trim(); - $input_elem.val(email); - } - $("#change_email_button").on("click", (e) => { e.preventDefault(); e.stopPropagation(); if (settings_data.user_can_change_email()) { dialog_widget.launch({ html_heading: $t_html({defaultMessage: "Change email"}), - html_body: render_change_email_modal(), + html_body: render_change_email_modal({delivery_email: page_params.delivery_email}), html_submit_button: $t_html({defaultMessage: "Change"}), loading_spinner: true, id: "change_email_modal", form_id: "change_email_form", on_click: do_change_email, - post_render: change_email_post_render, on_shown() { $("#change_email_form input").trigger("focus"); }, diff --git a/web/templates/change_email_modal.hbs b/web/templates/change_email_modal.hbs index 2bd961d135394..c30e5ecf62ee6 100644 --- a/web/templates/change_email_modal.hbs +++ b/web/templates/change_email_modal.hbs @@ -1,4 +1,4 @@
- +