From 1350157fdf1f035514aac9b5c629085eea9cce41 Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Mon, 17 Jun 2024 20:00:55 +0200 Subject: [PATCH] profile-fields: Check for date fields before initializing flatpickr. --- web/src/custom_profile_fields_ui.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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,