gregnb / gregnb/mui-datatables
Default sort order is not applied if any column's sortDirection is undefined
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
I came across this issue while I was trying to manually control the sorting state outside of the `MUIDataTable` component.
Because only one column can be sorted, I tried setting the sort direction of the previous column to `undefined` and applying the new sort direction to the current column, but this didn't do anything. Removing the `sortDirection` key from the options object instead of setting it to `undefined` results in the expected behavior.
## Expected Behavior
There shouldn't be a difference whether `sortDirection` is `undefined`, or the key doesn't exist.
## Current Behavior
If any column's sort direction is set to `undefined`, nothing happens.
## Steps to Reproduce (for bugs)
1. Open [codesandbox](https://codesandbox.io/s/muidatatables-sortdirection-undefined-r7j0z)
2. Table isn't sorted by the Name field
3. Remove Title options
4. Table is now sorted
## Your Environment
| Tech | Version |
|--------------|---------|
| MUI-datatables | 2.12.0 |
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.