diff --git a/packages/mantine-react-table/src/fns/filterFns.ts b/packages/mantine-react-table/src/fns/filterFns.ts index 398a7b257..474009dee 100644 --- a/packages/mantine-react-table/src/fns/filterFns.ts +++ b/packages/mantine-react-table/src/fns/filterFns.ts @@ -33,7 +33,7 @@ const contains = ( ) => row .getValue(id) - .toString() + ?.toString() .toLowerCase() .trim() .includes(filterValue.toString().toLowerCase().trim()); @@ -47,7 +47,7 @@ const startsWith = ( ) => row .getValue(id) - .toString() + ?.toString() .toLowerCase() .trim() .startsWith(filterValue.toString().toLowerCase().trim()); @@ -61,7 +61,7 @@ const endsWith = ( ) => row .getValue(id) - .toString() + ?.toString() .toLowerCase() .trim() .endsWith(filterValue.toString().toLowerCase().trim()); @@ -73,7 +73,7 @@ const equals = ( id: string, filterValue: number | string, ) => - row.getValue(id).toString().toLowerCase().trim() === + row.getValue(id)?.toString().toLowerCase().trim() === filterValue?.toString().toLowerCase().trim(); equals.autoRemove = (val: any) => !val; @@ -83,7 +83,7 @@ const notEquals = ( id: string, filterValue: number | string, ) => - row.getValue(id).toString().toLowerCase().trim() !== + row.getValue(id)?.toString().toLowerCase().trim() !== filterValue.toString().toLowerCase().trim(); notEquals.autoRemove = (val: any) => !val; @@ -95,7 +95,7 @@ const greaterThan = ( ) => !isNaN(+filterValue) && !isNaN(+row.getValue(id)) ? +row.getValue(id) > +filterValue - : row.getValue(id).toString().toLowerCase().trim() > + : row.getValue(id)?.toString().toLowerCase().trim() > filterValue?.toString().toLowerCase().trim(); greaterThan.autoRemove = (val: any) => !val; @@ -115,7 +115,7 @@ const lessThan = ( ) => !isNaN(+filterValue) && !isNaN(+row.getValue(id)) ? +row.getValue(id) < +filterValue - : row.getValue(id).toString().toLowerCase().trim() < + : row.getValue(id)?.toString().toLowerCase().trim() < filterValue?.toString().toLowerCase().trim(); lessThan.autoRemove = (val: any) => !val; @@ -162,7 +162,7 @@ const empty = ( row: Row, id: string, _filterValue: number | string, -) => !row.getValue(id).toString().trim(); +) => !row.getValue(id)?.toString().trim(); empty.autoRemove = (val: any) => !val; @@ -170,7 +170,7 @@ const notEmpty = ( row: Row, id: string, _filterValue: number | string, -) => !!row.getValue(id).toString().trim(); +) => !!row.getValue(id)?.toString().trim(); notEmpty.autoRemove = (val: any) => !val;