Skip to content

Commit

Permalink
fix: only remove date field if undefined (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
turban authored Sep 23, 2020
1 parent 9350aa2 commit 9493979
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/periods/StartEndDates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import styles from '../edit/LayerDialogStyles';

const StartEndDates = props => {
const { startDate, endDate, setStartDate, setEndDate, errorText } = props;
const hasDate = startDate !== undefined && endDate !== undefined;

useEffect(() => {
if (!startDate && !endDate) {
if (!hasDate) {
setStartDate(DEFAULT_START_DATE);
setEndDate(DEFAULT_END_DATE);
}
}, [startDate, endDate, setStartDate, setEndDate]);
}, [hasDate, setStartDate, setEndDate]);

return startDate && endDate ? (
return hasDate ? (
<Fragment>
<DatePicker
label={i18n.t('Start date')}
Expand Down

0 comments on commit 9493979

Please sign in to comment.