mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix filtering of empty reflists
Summary: A formula returning an empty RecordSet in a RefList columns results in storing [] instead of null. This caused a bug where the empty list was 'flattened' and the cell not appearing in filters at all. This diff fixes the bug by filtering for the default value `null` instead for RefLists and the empty string for ChoiceLists. I didn't manage to actually reproduce the bug for ChoiceLists, but this seemed the most sensible thing to do. Test Plan: New nbrowser test. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3478
This commit is contained in:
@@ -35,7 +35,11 @@ export function makeFilterFunc(state: FilterState,
|
||||
return (val: CellValue) => {
|
||||
if (isList(val) && columnType && isListType(columnType)) {
|
||||
const list = decodeObject(val) as unknown[];
|
||||
return list.some(item => values.has(item as any) === include);
|
||||
if (list.length) {
|
||||
return list.some(item => values.has(item as any) === include);
|
||||
}
|
||||
// If the list is empty, filter instead by an empty value for the whole list
|
||||
val = columnType === "ChoiceList" ? "" : null;
|
||||
}
|
||||
return (values.has(Array.isArray(val) ? JSON.stringify(val) : val) === include);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user