From 16f89989f0132dee0f1c985e067bb8cfbbccc5dc Mon Sep 17 00:00:00 2001 From: Martins Linde Date: Sun, 20 Jan 2019 08:03:24 +0200 Subject: [PATCH] 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 --- .../react-bootstrap-table2-filter/src/components/date.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-bootstrap-table2-filter/src/components/date.js b/packages/react-bootstrap-table2-filter/src/components/date.js index be6ecd5..5a6b1aa 100644 --- a/packages/react-bootstrap-table2-filter/src/components/date.js +++ b/packages/react-bootstrap-table2-filter/src/components/date.js @@ -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); }); } }