custom_profile_fields: Fix multiple modals opening.

Earlier the focus remained on the button to open the modal,
causing multiple modals to open on pressing enter repeatedly.
This commit fixes the issue by removing the focus from the button
by focusing on the first input field of the modal.
This commit is contained in:
Kenneth Rodrigues 2024-07-23 13:05:06 +05:30 committed by Tim Abbott
parent 55884b1338
commit fe557bde77
1 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import type {CustomProfileField} from "./state_data";
import {current_user, realm} from "./state_data";
import type {HTMLSelectOneElement, UserExternalAccountData} from "./types";
import * as ui_report from "./ui_report";
import {place_caret_at_end} from "./ui_util";
type FieldChoice = {
value: string;
@ -280,6 +281,9 @@ function open_custom_profile_field_form_modal(): void {
on_click: create_profile_field,
post_render: set_up_form_fields,
loading_spinner: true,
on_shown() {
$("#profile_field_type").trigger("focus");
},
});
}
@ -572,6 +576,9 @@ function open_edit_form_modal(this: HTMLElement): void {
on_click: submit_form,
post_render: set_initial_values_of_profile_field,
loading_spinner: true,
on_shown() {
place_caret_at_end($("#id-custom-profile-field-name")[0]!);
},
});
}