Skip to content

Commit 661715d

Browse files
fix(print): accept null datepicker values in date range
Refs: PS-275
1 parent 7a74282 commit 661715d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/components/form/partitions/DateRange.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
startOfDay,
77
subDays,
88
} from 'date-fns';
9-
import fi from 'date-fns/locale/fi';
10-
import sv from 'date-fns/locale/sv';
9+
import { fi, sv } from 'date-fns/locale';
1110
import { FormikErrors, FormikTouched } from 'formik';
1211
import React from 'react';
1312
import { Event } from '../../../store/types';
@@ -83,7 +82,10 @@ const DateRange: React.FC<Props> = ({
8382
};
8483

8584
const handleDateChange =
86-
(id: string, oldDate: Date | string | undefined) => (value: Date) => {
85+
(id: string, oldDate: Date | string | undefined) =>
86+
(value: Date | null) => {
87+
if (!value) return;
88+
8789
const oldDateObj = ensureDate(oldDate);
8890
onChange(id)(
8991
oldDateObj ? setHours(value, oldDateObj.getHours()) : addHours(value, 9)

0 commit comments

Comments
 (0)