diff --git a/src/view/plugin/sort/sort.tsx b/src/view/plugin/sort/sort.tsx index 3dd1e6d6..0b54e144 100644 --- a/src/view/plugin/sort/sort.tsx +++ b/src/view/plugin/sort/sort.tsx @@ -15,6 +15,8 @@ import { useStore } from '../../../hooks/useStore'; // column specific config export interface SortConfig { compare?: Comparator; + // 1 ascending, -1 descending + direction?: 1 | -1; } // generic sort config: @@ -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]);