diff --git a/client/src/app/pages/migration-waves/components/migration-wave-form.tsx b/client/src/app/pages/migration-waves/components/migration-wave-form.tsx index a7983cada..2b098417c 100644 --- a/client/src/app/pages/migration-waves/components/migration-wave-form.tsx +++ b/client/src/app/pages/migration-waves/components/migration-wave-form.tsx @@ -222,9 +222,13 @@ export const WaveForm: React.FC = ({ }); const startDateStr = watch("startDateStr"); + const endDateStr = watch("endDateStr"); const startDate = dateStrFormatValidator(startDateStr) ? dayjs(startDateStr).toDate() : null; + const endDate = dateStrFormatValidator(endDateStr) + ? dayjs(endDateStr).toDate() + : null; const onSubmit = (formValues: WaveFormValues) => { const stakeholders = @@ -315,7 +319,7 @@ export const WaveForm: React.FC = ({ aria-label={name} onChange={(e, val) => { onChange(val); - trigger("endDateStr"); + if (endDate) trigger("endDateStr"); }} placeholder="MM/DD/YYYY" value={value} @@ -356,6 +360,7 @@ export const WaveForm: React.FC = ({ dateFormat={(val) => dayjs(val).format("MM/DD/YYYY")} dateParse={(val) => dayjs(val).toDate()} validators={[endDateRangeValidator]} + rangeStart={startDate ? startDate : undefined} appendTo={() => endDateRef.current || document.body} /> )}