Skip to content

Commit

Permalink
fix(filters): filter by null [skip ci] (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeRego committed Feb 28, 2022
1 parent d357c4f commit 64b4a51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ export const getFilterRuleWithDefaultValue = <T extends FilterRule>(
}
return {
...filterRule,
values: value !== undefined ? [value] : [],
values: value !== undefined && value !== null ? [value] : [],
settings: undefined,
...filterRuleDefaults,
};
Expand All @@ -498,7 +498,8 @@ export const createFilterRuleFromField = (
target: {
fieldId: fieldId(field),
},
operator: FilterOperator.EQUALS,
operator:
value === null ? FilterOperator.NULL : FilterOperator.EQUALS,
},
value,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ export const CellContextMenu: React.FC<CellContextMenuProps> = ({
<MenuItem
text={`Filter by "${cell.value}"`}
onClick={() => {
addFilter(field, cell.value, true);
addFilter(
field,
cell.value === undefined
? null
: cell.value,
true,
);
}}
/>
</Menu>
Expand Down

0 comments on commit 64b4a51

Please sign in to comment.