Skip to content

Commit

Permalink
Merge pull request #1366 from mayorbyrne/initial_sort
Browse files Browse the repository at this point in the history
feat: add ability to initially sort a column descending
  • Loading branch information
afshinm committed Mar 3, 2024
2 parents df24682 + 70ef0d7 commit dd8985e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/view/plugin/sort/sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { useStore } from '../../../hooks/useStore';
// column specific config
export interface SortConfig {
compare?: Comparator<TCell>;
// 1 ascending, -1 descending
direction?: 1 | -1;
}

// generic sort config:
Expand Down Expand Up @@ -96,6 +98,11 @@ export function Sort(
if (!currentColumn) {
setDirection(0);
} else {
// if the direction is not set, initialize the selected
// column direction with the passed prop (default to ascending)
if (direction === 0) {
currentColumn.direction = props.direction ?? 1;
}
setDirection(currentColumn.direction);
}
}, [state]);
Expand Down

0 comments on commit dd8985e

Please sign in to comment.