profile-fields: Check for date fields before initializing flatpickr.

This commit is contained in:
Lauryn Menard 2024-06-17 20:00:55 +02:00 committed by Tim Abbott
parent 5e42c8cd2b
commit 1350157fdf
1 changed files with 6 additions and 1 deletions

View File

@ -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,