KevinVandy / material-react-table

A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript
https://material-react-table.com
MIT License
1.55k stars 454 forks source link

Can't sort the column with type of property is number in manualSorting=true #1183

Open nguyenhieudeptrai opened 4 months ago

nguyenhieudeptrai commented 4 months ago

material-react-table version

2.13.0

react & react-dom versions

18.0.0

Describe the bug and the steps to reproduce it

My data is[{ index: 1, name: "a" }, { index: 2, name: "b" }]

My state is { sortType: 1} // sortType is 1 or 2 (required)`

const columns=[
{ accessorKey: 'index', header: 'My index' },
{ accessorKey: 'name', header: 'Name' }
];

const setMySortType =(arr) => {
 arr[0] && setState({ sortType: arr[0].desc ? 2 : 1 });
}

const config= useMaterialReactTable({
 columns: columns,
 data: data,
 manualSorting: true, // my project requires to manually sort
 onSortingChange: (func) => setMySortType(func()),
 state: {
     sorting: [{ id: "index", desc: state.sortType == 2 }] 
 }
});

I clicked on the label until the 3rd time and there was no change in sort direction and the value remained the same as last time. The first 2 times, it was ok. With the string property, it sorts the data normally for all.

Looking forward to your support <3

Minimal, Reproducible Example - (Optional, but Recommended)

//

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

None

Terms

KevinVandy commented 4 months ago

I don't quite understand what is being reported here. A sandbox repro would be helpful