Ensured the 'all' item is selected when custom date ranges are unselected

This commit is contained in:
Alejandro Celaya 2021-10-03 21:09:48 +02:00
parent c71e0919e9
commit 4c1d285d04

View file

@ -29,7 +29,7 @@ export const DateRangeSelector = (
!rangeIsInterval(initialDateRange) ? initialDateRange : undefined,
);
const updateDateRange = (dateRange: DateRange) => {
setActiveInterval(undefined);
setActiveInterval(dateRangeIsEmpty(dateRange) ? 'all' : undefined);
setActiveDateRange(dateRange);
onDatesChange(dateRange);
};
@ -43,7 +43,7 @@ export const DateRangeSelector = (
<DropdownBtn disabled={disabled} text={rangeOrIntervalToString(activeInterval ?? activeDateRange) ?? defaultText}>
<DateIntervalDropdownItems
allText={defaultText}
active={!dateRangeIsEmpty(activeDateRange) ? undefined : activeInterval}
active={activeInterval}
onChange={(interval) => updateInterval(interval)()}
/>
<DropdownItem divider />