From ca323a50734336b960d1b732aa97a9de9c8a3749 Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Mon, 26 Aug 2024 08:45:07 -0700 Subject: [PATCH 1/3] fix(input-date-picker): fix console error with date formatting. --- .../components/input-date-picker/input-date-picker.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx b/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx index 185ccdd35f6..3978a33b831 100644 --- a/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx +++ b/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx @@ -527,6 +527,7 @@ export class InputDatePicker componentDidLoad(): void { setComponentLoaded(this); + this.handleDateTimeFormatChange(); this.localizeInputValues(); connectFloatingUI(this, this.referenceEl, this.floatingEl); } @@ -1089,8 +1090,11 @@ export class InputDatePicker ) : null; - this.setInputValue((date && this.dateTimeFormat.format(date)) ?? "", "start"); - this.setInputValue((this.range && endDate && this.dateTimeFormat.format(endDate)) ?? "", "end"); + this.setInputValue((date && this.dateTimeFormat?.format(date)) ?? "", "start"); + this.setInputValue( + (this.range && endDate && this.dateTimeFormat?.format(endDate)) ?? "", + "end", + ); } private setInputValue = (newValue: string, input: "start" | "end" = "start"): void => { From f6eb0b2d124bfda50e2e1758020b82244f28b139 Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Mon, 26 Aug 2024 09:09:43 -0700 Subject: [PATCH 2/3] cleanup --- .../src/components/input-date-picker/input-date-picker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx b/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx index 3978a33b831..b3eb6f096a9 100644 --- a/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx +++ b/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx @@ -468,6 +468,7 @@ export class InputDatePicker connectedCallback(): void { connectInteractive(this); connectLocalized(this); + this.handleDateTimeFormatChange(); const { open } = this; open && this.openHandler(); @@ -527,7 +528,6 @@ export class InputDatePicker componentDidLoad(): void { setComponentLoaded(this); - this.handleDateTimeFormatChange(); this.localizeInputValues(); connectFloatingUI(this, this.referenceEl, this.floatingEl); } From 0600f3ac020fd1fbc3332b4baff00db374ef8a30 Mon Sep 17 00:00:00 2001 From: Matt Driscoll Date: Mon, 26 Aug 2024 16:51:49 -0700 Subject: [PATCH 3/3] review fixes --- .../src/components/input-date-picker/input-date-picker.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx b/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx index b3eb6f096a9..f2bbe700d71 100644 --- a/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx +++ b/packages/calcite-components/src/components/input-date-picker/input-date-picker.tsx @@ -1090,11 +1090,8 @@ export class InputDatePicker ) : null; - this.setInputValue((date && this.dateTimeFormat?.format(date)) ?? "", "start"); - this.setInputValue( - (this.range && endDate && this.dateTimeFormat?.format(endDate)) ?? "", - "end", - ); + this.setInputValue((date && this.dateTimeFormat.format(date)) ?? "", "start"); + this.setInputValue((this.range && endDate && this.dateTimeFormat.format(endDate)) ?? "", "end"); } private setInputValue = (newValue: string, input: "start" | "end" = "start"): void => {