Allow null date when clearing date filter with getFilter function (#759)

* fix date filter's getFilter function to accept empty value for clearing

* syntax improvements from ESlint
This commit is contained in:
Martins Linde 2019-01-20 08:03:24 +02:00 committed by Allen
parent 416fcf08d4
commit 16f89989f0

View File

@ -42,10 +42,11 @@ class DateFilter extends Component {
// export onFilter function to allow users to access
if (getFilter) {
getFilter((filterVal) => {
this.dateFilterComparator.value = filterVal.comparator;
this.inputDate.value = dateParser(filterVal.date);
const nullableFilterVal = filterVal || { date: null, comparator: null };
this.dateFilterComparator.value = nullableFilterVal.comparator;
this.inputDate.value = nullableFilterVal.date ? dateParser(nullableFilterVal.date) : null;
this.applyFilter(filterVal.date, filterVal.comparator);
this.applyFilter(nullableFilterVal.date, nullableFilterVal.comparator);
});
}
}