Fix Unselected Enum Filters Showing up

Summary:
Filter type enum works differently than what I understood; its value is not inside the column.

Move the enum checking to before others because text matching relies on column value.

In addition, change the behavior when there is no column (from ignoring the search to causing all row to disappear due to mismatch ing)

Reviewed By: mweststrate

Differential Revision: D19345758

fbshipit-source-id: d49bc0e29d7a3d36f3aad20213791211c2c3065b
This commit is contained in:
Chaiwat Ekkaewnumchai
2020-01-10 08:48:10 -08:00
committed by Facebook Github Bot
parent 40f9b385bb
commit 2f0f694cf5

View File

@@ -30,16 +30,17 @@ type State = {
const rowMatchesFilters = (filters: Array<Filter>, row: TableBodyRow) =>
filters
.map((filter: Filter) => {
// Check if there is column name and value. If not, ignore
if (filter.type === 'enum' && row.type != null) {
return filter.value.length === 0 || filter.value.indexOf(row.type) > -1;
}
// Check if there is column name and value in case of mistyping.
if (
row.columns[filter.key] === undefined ||
row.columns[filter.key].value === undefined
) {
return true;
return false;
}
if (filter.type === 'enum' && row.type != null) {
return filter.value.length === 0 || filter.value.indexOf(row.type) > -1;
} else if (filter.type === 'include') {
if (filter.type === 'include') {
return (
textContent(row.columns[filter.key].value).toLowerCase() ===
filter.value.toLowerCase()