Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #545 - exception in defaultColumnFilter on null values #546

Open
wants to merge 3 commits into
base: v0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scripts/__tests__/griddle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ describe('Griddle', function() {
expect(grid.state.filteredResults.length).toEqual(1);
});

it('correctly handles a null value in defaultColumnFilter', function(){
const test = grid.defaultColumnFilter(null, 'May');
expect(test).toEqual(false);
});

it('sets the filteredResults when filterByColumn called on object field', function(){
grid.filterByColumn('Hawaii', 'address');
expect(grid.state.filteredResults.length).toEqual(1);
Expand Down
4 changes: 3 additions & 1 deletion scripts/griddle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ var Griddle = React.createClass({

defaultColumnFilter(value, filter) {
return _filter(deep.getObjectValues(value), function(value) {
return value.toString().toLowerCase().indexOf(filter.toLowerCase()) >= 0;
if (value !== null && value.toString) {
return value.toString().toLowerCase().indexOf(filter.toLowerCase()) >= 0;
}
}).length > 0;
},

Expand Down