material-react-table icon indicating copy to clipboard operation
material-react-table copied to clipboard

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

Open nguyenhieudeptrai opened this issue 1 year ago • 1 comments

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

  • [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.

nguyenhieudeptrai avatar Jul 11 '24 08:07 nguyenhieudeptrai

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

KevinVandy avatar Jul 28 '24 23:07 KevinVandy