Skip to content

Commit 6f15e8e

Browse files
committed
fix: fix sort state not unsetting when clicked 3 times
1 parent 6f95169 commit 6f15e8e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ui/DataTable/Hooks/useReactTableSortState.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ export default function useReactTableSortState(
3232

3333
const updateSortByFn = useCallback(
3434
(newSortBy: Updater<SortingState>) => {
35-
const sort = typeof newSortBy === "function" ? newSortBy([]) : newSortBy;
35+
const sort =
36+
typeof newSortBy === "function"
37+
? newSortBy([...tableSortByState])
38+
: newSortBy;
3639
if (sort.length === 0) {
3740
searchParams.delete(sortByKey);
3841
searchParams.delete(sortOrderKey);
@@ -42,7 +45,7 @@ export default function useReactTableSortState(
4245
}
4346
setSearchParams(searchParams);
4447
},
45-
[searchParams, setSearchParams, sortByKey, sortOrderKey]
48+
[searchParams, setSearchParams, sortByKey, sortOrderKey, tableSortByState]
4649
);
4750

4851
return [tableSortByState, updateSortByFn];

0 commit comments

Comments
 (0)