Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

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

Lauryn Menard1350157fdf1f
diff --git a/web/src/custom_profile_fields_ui.ts b/web/src/custom_profile_fields_ui.ts
index 764ad23e589..15b180a1b87 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,