material-react-table
material-react-table copied to clipboard
Column filter mode is undefined if initialState of showColumnFilters is not set to true.
material-react-table version
latest
react & react-dom versions
latest
Describe the bug and the steps to reproduce it
Column filter mode (for each column) is undefined (none checked) if initialState of showColumnFilters is not set to true. Default should be fuzzy
Minimal, Reproducible Example - (Optional, but Recommended)
<MaterialReactTable columns={columns} data={data} //10,000 rows defaultDisplayColumn={{ enableResizing: true }} enableColumnResizing enableColumnOrdering enableColumnFilterModes enablePagination muiSearchTextFieldProps={{ sx: { minWidth: '300px', }, variant: 'outlined' }} initialState={{ showGlobalFilter: true, showColumnFilters: false }} />
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
No, because I do not have time to dig into it
Terms
- [X] I understand that if my bug cannot be reliably reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
I have not been quite able to reproduce this. Here's an example where the bug should be present if it is there, but it is not happening for me: https://www.material-react-table.dev/?path=/story/features-filtering-examples--filtering-change-mode-enabled-hidden
I have seen this happen. When Next.js hot reloads, the filter mode gets set to undefined. I haven't seen this happen outside of hot reloading.
"next": "13.2.4"
"material-react-table": "^1.9.1"
I have the same problem when const [columnFilterFns, setColumnFilterFns] = useState(); is not empty
In TypeScript I can't leave this empty so my default value is an empty object, but with an empty object everything will be "Undefined"
Leaving it empty, onColumnFilterFnsChange will get this error:
Types of parameters 'value' and 'updaterOrValue' are incompatible.
Type 'Updater<{ [key: string]: MRT_FilterOption; }>' is not assignable to type 'SetStateAction<undefined>'.
Type '{ [key: string]: MRT_FilterOption; }' is not assignable to type 'SetStateAction<undefined>'.
Type '{ [key: string]: MRT_FilterOption; }' provides no match for the signature '(prevState: undefined): undefined'.ts(2322)
index.d.ts(772, 5): The expected type comes from property 'onColumnFilterFnsChange' which is declared here on type 'IntrinsicAttributes & { meta?: TableMeta<{}> | undefined; enableHiding?: boolean | undefined; enablePinning?: boolean | undefined; enableGlobalFilter?: boolean | undefined; ... 179 more ...; virtualizerProps?: any; } & { ...; }'```
I have go the exact same problem using Vite, but not only on hot reload. The problem only appears with "fuzzy" as default.