[Tables] Filtering fails when one or more cells contain undefined value #2493 (#2510)

* [Tables] Filtering fails when one or more cells contain undefined value #2493

* refactored to handle edge cases first
This commit is contained in:
Nikhil 2019-10-10 12:46:25 -07:00 committed by Andrew Henry
parent ff5b88b544
commit 2ecff75da5

View File

@ -87,14 +87,18 @@ define(
matchesFilters(row) {
let doesMatchFilters = true;
for (const key in this.columnFilters) {
if (!this.rowHasColumn(row, key)) {
if (!doesMatchFilters || !this.rowHasColumn(row, key)) {
return false;
} else {
let formattedValue = row.getFormattedValue(key).toLowerCase();
doesMatchFilters = doesMatchFilters &&
formattedValue.indexOf(this.columnFilters[key]) !== -1;
}
let formattedValue = row.getFormattedValue(key);
if (formattedValue === undefined) {
return false;
}
doesMatchFilters = formattedValue.toLowerCase().indexOf(this.columnFilters[key]) !== -1;
}
return doesMatchFilters;
}