From 90d03676ada945733a6086baff7cf3203f4a02d1 Mon Sep 17 00:00:00 2001 From: Nathan Date: Mon, 16 Jul 2018 18:06:51 -0400 Subject: [PATCH 1/2] import numberFilter in numberFilter example --- packages/react-bootstrap-table2-filter/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-bootstrap-table2-filter/README.md b/packages/react-bootstrap-table2-filter/README.md index 0af54da..6cf47a0 100644 --- a/packages/react-bootstrap-table2-filter/README.md +++ b/packages/react-bootstrap-table2-filter/README.md @@ -131,7 +131,7 @@ const columns = [..., { Numner filter is same as other filter, you can custom the number filter via `numberFilter` factory function: ```js -import filterFactory, { selectFilter, Comparator } from 'react-bootstrap-table2-filter'; +import filterFactory, { selectFilter, Comparator, numberFilter } from 'react-bootstrap-table2-filter'; // omit... const numberFilter = numberFilter({ @@ -240,4 +240,4 @@ Following properties is valid in `FILTER_TYPES`: * TEXT * SELECT * NUMBER -* DATE \ No newline at end of file +* DATE From 6522f6d964a0df32a2f4ec43270a33cba6357292 Mon Sep 17 00:00:00 2001 From: Benny Johnson Date: Tue, 24 Jul 2018 23:20:35 -0400 Subject: [PATCH 2/2] Commented out a check which caused the date filter to not update the (#425) table when the date or date comparator were cleared Modified applyFilter in date.js so that it doesn't try to parse an Invalid Date. It was parsing an empty string, which caused it to pass through an invalid date to onFilter, and this wasn't being checked for properly by the onFilter function. It now checks for the empty string and passes in null, which is what the onFilter function was actually checking for --- .../src/components/date.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/react-bootstrap-table2-filter/src/components/date.js b/packages/react-bootstrap-table2-filter/src/components/date.js index 02468aa..8e31724 100644 --- a/packages/react-bootstrap-table2-filter/src/components/date.js +++ b/packages/react-bootstrap-table2-filter/src/components/date.js @@ -93,12 +93,16 @@ class DateFilter extends Component { } applyFilter(value, comparator) { - if (!comparator || !value) { - return; - } + // if (!comparator || !value) { + // return; + // } const { column, onFilter, delay } = this.props; const execute = () => { - const date = typeof value !== 'object' ? new Date(value) : value; + // Incoming value should always be a string, and the defaultDate + // above is implemented as an empty string, so we can just check for that. + // instead of parsing an invalid Date. The filter function will interpret + // null as an empty date field + const date = value === '' ? null : new Date(value); onFilter(column, FILTER_TYPE.DATE)({ date, comparator }); }; if (delay) {