Closed BendixP closed 1 year ago
fixed in v2, backported to v1.15.1
Unfortunately there is still a problem when sorting is not disabled: https://codesandbox.io/p/sandbox/dawn-sound-64tkh7?file=%2Fsrc%2FTS.tsx%3A41%2C31 Should i open a new issue?
With deep accessor keys also get undefined value warnings from https://github.com/TanStack/table/blob/a1e9732e6fc3446a2ae80db72a1f2b46a5c11e46/packages/table-core/src/core/column.ts#L101
With deep accessor keys also get undefined value warnings from https://github.com/TanStack/table/blob/a1e9732e6fc3446a2ae80db72a1f2b46a5c11e46/packages/table-core/src/core/column.ts#L101
That's actually by design. In fact, we used to throw an error in this situation in earlier versions. If you have inconsistent data structures that need to be handled, I recommend using an accessorFn
instead of accessorKey
so that you can handle optional chaining and fallback values gracefully how you need to.
Unfortunately there is still a problem when sorting is not disabled: https://codesandbox.io/p/sandbox/dawn-sound-64tkh7?file=%2Fsrc%2FTS.tsx%3A41%2C31 Should i open a new issue?
Just found what I needed to short-circuit in the sorting tooltip for that. Will be fixing it immediately for v2. Adding optional chaining in your accessorFn
also fixes this as when blank cells are created, they are given all null
values in every column, which causes problems when you call string methods. TypeScript is not warning you about this, so easy to make this error.
Just found what I needed to short-circuit in the sorting tooltip for that. Will be fixing it immediately for v2. Adding optional chaining in your
accessorFn
also fixes this as when blank cells are created, they are given allnull
values in every column, which causes problems when you call string methods. TypeScript is not warning you about this, so easy to make this error.
Will that fix be backported as well?
I'll probably do one more batch of backported fixes. I planning to release v2 as stable this weekend though
This is noted as fixed in the v1.15.1 changelog, but does not appear to have been backported.
This is noted as fixed in the v1.15.1 changelog, but does not appear to have been backported.
Ok yes. If sorting is enabled, the bug is still there. But just update to the latest v2 release and it's fixed.
material-react-table version
1.15.0
react & react-dom versions
18.2.0
Describe the bug and the steps to reproduce it
When the table is in a loading state and showing skeleton rows, the accessor funtion is called with the dummy row, that has undefined values for all its relevant properties. This was not the case in previous versions. It causes problems because the type of accessorFn doesn't necessarily take into account the possibility of undefined values coming in. Probably the accessorFn should not be called at all in the loading state.
Minimal, Reproducible Example - (Optional, but Recommended)
https://codesandbox.io/p/sandbox/recursing-tristan-55ph8q?file=%2Fpackage.json%3A11%2C5
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms