Description
Provide a general summary of the issue here
I'm trying to mix two examples into one working - dynamic table with sorting.
https://react-spectrum.adobe.com/react-aria/Table.html#content
https://react-spectrum.adobe.com/react-aria/Table.html#sorting
The issue is that onSortChange
callback doesn't receive sortDescriptor.column as key of the column, but random string react-aria-1
...
Also the confusing part is that for dynamic table header columns are defined:
let columns = [
{name: 'Name', key: 'name', isRowHeader: true},
{name: 'Type', key: 'type'},
{name: 'Date Modified', key: 'date'}
];
<Table
aria-label="Example table with client side sorting"
sortDescriptor={list.sortDescriptor}
onSortChange={list.sort}
>
<TableHeader>
<MyColumn id="name" isRowHeader allowsSorting>Name</MyColumn>
<MyColumn id="height" allowsSorting>Height</MyColumn>
<MyColumn id="mass" allowsSorting>Mass</MyColumn>
<MyColumn id="birth_year" allowsSorting>Birth Year</MyColumn>
</TableHeader>
<TableBody items={list.items}>
{(item) => (
<Row id={item.name}>
<Cell>{item.name}</Cell>
<Cell>{item.height}</Cell>
<Cell>{item.mass}</Cell>
<Cell>{item.birth_year}</Cell>
</Row>
)}
</TableBody>
</Table>
🤔 Expected Behavior?
When using dynamic table with sorting, sortDescriptor.column should be key from columns array definition
😯 Current Behavior
When using dynamic table with sorting, sortDescriptor.column is react-aria-1
, react-aria-2
...
💁 Possible Solution
No response
🔦 Context
I think the problem is related how Collection is handling items (columns)
🖥️ Steps to Reproduce
https://codesandbox.io/s/wizardly-fast-zsmnww
Version
1.0.0-beta.1
What browsers are you seeing the problem on?
Microsoft Edge
If other, please specify.
No response
What operating system are you using?
Windows 10
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response