mirror of https://github.com/zulip/zulip.git
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.
This commit is contained in:
parent
25fb810d81
commit
90205a490d
|
@ -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");
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<form id="change_email_form" class="new-style">
|
||||
<label for="email">{{t "New email" }}</label>
|
||||
<input type="text" name="email" value="{{ page_params.delivery_email }}" autocomplete="off" spellcheck="false" autofocus="autofocus"/>
|
||||
<input type="text" name="email" value="{{delivery_email}}" autocomplete="off" spellcheck="false" autofocus="autofocus"/>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue