diff --git a/web/src/custom_profile_fields_ui.ts b/web/src/custom_profile_fields_ui.ts index 764ad23e58..15b180a1b8 100644 --- a/web/src/custom_profile_fields_ui.ts +++ b/web/src/custom_profile_fields_ui.ts @@ -151,7 +151,12 @@ export function initialize_custom_user_type_fields( } export function initialize_custom_date_type_fields(element_id: string): void { - flatpickr($(element_id).find(".custom_user_field .datepicker")[0]!, { + const $date_picker_elements = $(element_id).find(".custom_user_field .datepicker"); + if ($date_picker_elements.length === 0) { + return; + } + + flatpickr($date_picker_elements, { altInput: true, altFormat: "F j, Y", allowInput: true,