Skip to content

Commit

Permalink
[tableOrderStore] Use initialDirection when changing column sorted by
Browse files Browse the repository at this point in the history
  • Loading branch information
techniq committed Mar 19, 2024
1 parent df12c94 commit 8ea0a4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/two-planes-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-ux": patch
---

[tableOrderStore] Use `initialDirection` when changing column sorted by
7 changes: 6 additions & 1 deletion packages/svelte-ux/src/lib/stores/tableOrderStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ export default function tableOrderStore(props?: TableOrderProps) {
? column.value
: column.name;

const direction = prevState.by === by && prevState.direction === 'asc' ? 'desc' : 'asc';
const direction =
prevState.by !== by
? props?.initialDirection ?? 'asc'
: prevState.direction === 'asc'
? 'desc'
: 'asc';

let handler: SortFunc | undefined = undefined;
if (isFunction(column.orderBy)) {
Expand Down

0 comments on commit 8ea0a4d

Please sign in to comment.