Skip to content

Commit

Permalink
default sort is ascending
Browse files Browse the repository at this point in the history
Signed-off-by: yaacov <yzamir@redhat.com>
  • Loading branch information
yaacov committed Jul 11, 2023
1 parent 532f0eb commit 2d238c1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('useSort hook', () => {
expect(activeSort).toMatchObject({
resourceFieldId: NAME,
label: NameColumn.label,
isAsc: false,
isAsc: true,
});
});

Expand All @@ -31,7 +31,7 @@ describe('useSort hook', () => {
expect(activeSort).toMatchObject({
resourceFieldId: 'Foo',
label: undefined,
isAsc: false,
isAsc: true,
});
});

Expand All @@ -45,7 +45,7 @@ describe('useSort hook', () => {
expect(activeSort).toMatchObject({
resourceFieldId: undefined,
label: undefined,
isAsc: false,
isAsc: true,
});

expect(setActiveSort).toBeDefined();
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/components/TableView/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const useSort = (
);

const [activeSort, setActiveSort] = useState<SortType>({
isAsc: false,
// when no other order is define, default to ascending order
isAsc: true,
resourceFieldId: firstField?.resourceFieldId,
label: firstField?.label,
});
Expand Down

0 comments on commit 2d238c1

Please sign in to comment.