Skip to content

Commit 9940504

Browse files
committed
Refactor date change handling in DateTimeField to ensure proper timezone formatting and fallback to ISO string
1 parent 76b103c commit 9940504

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/panelWebView/components/Fields/DateTimeField.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ export const DateTimeField: React.FunctionComponent<IDateTimeFieldProps> = ({
4040
const onDateChange = React.useCallback((date: Date) => {
4141
setDateValue(date);
4242
if (format) {
43+
// Always use DateHelper.formatInTimezone when a format is provided
4344
onChange(DateHelper.formatInTimezone(date, format, timezone) || "");
4445
} else {
46+
// Only fallback to ISO string if no format is provided
4547
onChange(date.toISOString());
4648
}
47-
}, [format, onChange]);
49+
}, [format, timezone, onChange]);
4850

4951
const showRequiredState = useMemo(() => {
5052
return required && !dateValue;

0 commit comments

Comments
 (0)