diff --git a/build/reactable.js b/build/reactable.js index 7671bed2..1da0fe88 100644 --- a/build/reactable.js +++ b/build/reactable.js @@ -1314,7 +1314,11 @@ window.ReactDOM["default"] = window.ReactDOM; } } else { // Apply custom filter - if (this._filterable[filterColumn]((0, _libExtract_data_from.extractDataFrom)(data, filterColumn).toString(), filter)) { + var rawData = (0, _libExtract_data_from.extractDataFrom)(data, filterColumn); + if (rawData.toString() !== '[object Object]') { + rawData = rawData.toString(); + } + if (this._filterable[filterColumn](rawData, filter)) { matchedChildren.push(children[i]); break; } diff --git a/lib/reactable/table.js b/lib/reactable/table.js index e2235b66..f8a1646e 100644 --- a/lib/reactable/table.js +++ b/lib/reactable/table.js @@ -321,7 +321,11 @@ var Table = (function (_React$Component) { } } else { // Apply custom filter - if (this._filterable[filterColumn]((0, _libExtract_data_from.extractDataFrom)(data, filterColumn).toString(), filter)) { + var rawData = (0, _libExtract_data_from.extractDataFrom)(data, filterColumn); + if (rawData.toString() !== '[object Object]') { + rawData = rawData.toString(); + } + if (this._filterable[filterColumn](rawData, filter)) { matchedChildren.push(children[i]); break; } diff --git a/src/reactable/table.jsx b/src/reactable/table.jsx index 82601180..4b095ccc 100644 --- a/src/reactable/table.jsx +++ b/src/reactable/table.jsx @@ -277,7 +277,11 @@ export class Table extends React.Component { } } else { // Apply custom filter - if (this._filterable[filterColumn](extractDataFrom(data, filterColumn).toString(), filter)) { + let rawData = extractDataFrom(data, filterColumn); + if (rawData.toString() !== '[object Object]') { + rawData = rawData.toString(); + } + if (this._filterable[filterColumn](rawData, filter)) { matchedChildren.push(children[i]); break; } diff --git a/tests/reactable_test.jsx b/tests/reactable_test.jsx index cd98a33c..447a0246 100644 --- a/tests/reactable_test.jsx +++ b/tests/reactable_test.jsx @@ -2421,6 +2421,60 @@ describe('Reactable', function() { }); }); }); + + + context('with custom filter and complex contents', function() { + before(function() { + this.component = ReactDOM.render( + -1 + ); + }, + } + ]} + filterPlaceholder="Filter Results" + columns={['State', 'Description', 'Tag']}> + +
New York
+ this is some text + new +
+ +
New Mexico
+ lorem ipsum + old x +
+ +
Colorado
+ lol + renewed x +
+ +
Alaska
+ bacon + new +
+
, + ReactableTestUtils.testNode() + ); + + this.component.filterBy('AK'); + }); + + after(ReactableTestUtils.resetTestEnvironment); + + it('filters based on a prop specified in the custom filter', function() { + ReactableTestUtils.expectRowText(0, ['Alaska', 'bacon', 'new']); + }); + }); + + }); describe('directly passing a data array with non-string data', function() {