From 2d238c1afdb23c8f2c9a978a7ac3ac75ec93faec Mon Sep 17 00:00:00 2001 From: yaacov Date: Tue, 11 Jul 2023 15:05:45 +0300 Subject: [PATCH] default sort is ascending Signed-off-by: yaacov --- .../src/components/TableView/__tests__/useSort.test.tsx | 6 +++--- packages/common/src/components/TableView/sort.ts | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/common/src/components/TableView/__tests__/useSort.test.tsx b/packages/common/src/components/TableView/__tests__/useSort.test.tsx index bba23ee16..2a8c6c782 100644 --- a/packages/common/src/components/TableView/__tests__/useSort.test.tsx +++ b/packages/common/src/components/TableView/__tests__/useSort.test.tsx @@ -17,7 +17,7 @@ describe('useSort hook', () => { expect(activeSort).toMatchObject({ resourceFieldId: NAME, label: NameColumn.label, - isAsc: false, + isAsc: true, }); }); @@ -31,7 +31,7 @@ describe('useSort hook', () => { expect(activeSort).toMatchObject({ resourceFieldId: 'Foo', label: undefined, - isAsc: false, + isAsc: true, }); }); @@ -45,7 +45,7 @@ describe('useSort hook', () => { expect(activeSort).toMatchObject({ resourceFieldId: undefined, label: undefined, - isAsc: false, + isAsc: true, }); expect(setActiveSort).toBeDefined(); diff --git a/packages/common/src/components/TableView/sort.ts b/packages/common/src/components/TableView/sort.ts index 1afbb9454..31643b690 100644 --- a/packages/common/src/components/TableView/sort.ts +++ b/packages/common/src/components/TableView/sort.ts @@ -66,7 +66,8 @@ export const useSort = ( ); const [activeSort, setActiveSort] = useState({ - isAsc: false, + // when no other order is define, default to ascending order + isAsc: true, resourceFieldId: firstField?.resourceFieldId, label: firstField?.label, });