rowExpansion bug: All rows expand
Describe the bug
In the rowExpansion feature...
If any/all records have a field name that starts with a capital letter, clicking on any row causes all rows to expand.
For instance:
const rows = [{ID: 123, "First Name": "Danny"}, {ID: 789, "First Name": "Eiter"}] causes all records to expand instead of the single row the user clicks.
A temporary workaround is to do the following:
const rows = [{id: 123, firstName: "Danny"}, {id: 789, firstName: "Eiter"}]
To Reproduce Steps to reproduce the behavior:
- Create a DataTable using the rows example I showed above.
- In the UI, expand the first row.
- All rows will expand.
Expected behavior Only one row should expand.
Screenshots N/A
Desktop (please complete the following information):
- OS: macOS
- Browser Chrome
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context TypeScript, NextJS
That's awkward :-) Well spotted, thanks. Will have a look and let you know as soon as it's fixed.
Your example almost got me fooled as well, but no, it's actually not a bug. and has nothing to do with capital letter columns.
It's easy to miss, but if you're using const rows = [{ID: 123, "First Name": "Danny"}, {ID: 789, "First Name": "Eiter"}] as a data source, it means you have a non-standard record id. The default idAccessor is 'id', and 'ID' !== 'id'.
So, if you want to keep your data source as it is, set the DataTable idAccessor to 'ID' like so:
<DataTable
columns={[{ accessor: 'ID' }, { accessor: 'First Name' }]}
records={[
{ ID: 123, 'First Name': 'Danny' },
{ ID: 789, 'First Name': 'Eiter' },
]}
idAccessor="ID" // 👉 because 'ID' !== 'id'
rowExpansion={{ content: () => <Box p="lg">Expanded</Box> }}
/>