diff --git a/packages/datagateway-download/src/downloadCart/downloadCartTable.component.test.tsx b/packages/datagateway-download/src/downloadCart/downloadCartTable.component.test.tsx index fa22a6f42..b5842c326 100644 --- a/packages/datagateway-download/src/downloadCart/downloadCartTable.component.test.tsx +++ b/packages/datagateway-download/src/downloadCart/downloadCartTable.component.test.tsx @@ -276,10 +276,10 @@ describe('Download cart table component', () => { rows = await screen.findAllByText(/(DATAFILE|DATASET|INVESTIGATION) \d/); // row should be sorted by type desc & name asc. - expect(rows[0]).toHaveTextContent('INVESTIGATION 1'); - expect(rows[1]).toHaveTextContent('INVESTIGATION 2'); - expect(rows[2]).toHaveTextContent('DATASET 1'); - expect(rows[3]).toHaveTextContent('DATAFILE 1'); + expect(rows[0]).toHaveTextContent('DATAFILE 1'); + expect(rows[1]).toHaveTextContent('DATASET 1'); + expect(rows[2]).toHaveTextContent('INVESTIGATION 1'); + expect(rows[3]).toHaveTextContent('INVESTIGATION 2'); await user.click(nameSortLabel); diff --git a/packages/datagateway-download/src/downloadCart/downloadCartTable.component.tsx b/packages/datagateway-download/src/downloadCart/downloadCartTable.component.tsx index 4c389d298..17963293c 100644 --- a/packages/datagateway-download/src/downloadCart/downloadCartTable.component.tsx +++ b/packages/datagateway-download/src/downloadCart/downloadCartTable.component.tsx @@ -194,9 +194,11 @@ const DownloadCartTable: React.FC = ( [t, textFilter] ); const onSort = React.useCallback( - (column: string, order: 'desc' | 'asc' | null) => { + (column: string, order: 'desc' | 'asc' | null, _, shiftDown?: boolean) => { if (order) { - setSort({ ...sort, [column]: order }); + shiftDown + ? setSort({ ...sort, [column]: order }) + : setSort({ [column]: order }); } else { const { [column]: order, ...restOfSort } = sort; setSort(restOfSort); diff --git a/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.test.tsx b/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.test.tsx index 9ed3db3a2..323f311c0 100644 --- a/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.test.tsx +++ b/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.test.tsx @@ -188,7 +188,8 @@ describe('Admin Download Status Table', () => { downloadApiUrl: mockedSettings.downloadApiUrl, facilityName: mockedSettings.facilityName, }, - `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.userName asc, download.transport asc, download.id ASC LIMIT 0, 50` + `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.transport asc, download.id ASC LIMIT 0, 50` + // `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.userName asc, download.transport asc, download.id ASC LIMIT 0, 50` ); await user.click(accessMethodSortLabel); @@ -197,7 +198,8 @@ describe('Admin Download Status Table', () => { downloadApiUrl: mockedSettings.downloadApiUrl, facilityName: mockedSettings.facilityName, }, - `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.userName asc, download.transport desc, download.id ASC LIMIT 0, 50` + `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.transport desc, download.id ASC LIMIT 0, 50` + // `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.userName asc, download.transport desc, download.id ASC LIMIT 0, 50` ); await user.click(accessMethodSortLabel); @@ -206,7 +208,8 @@ describe('Admin Download Status Table', () => { downloadApiUrl: mockedSettings.downloadApiUrl, facilityName: mockedSettings.facilityName, }, - `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.userName asc, download.id ASC LIMIT 0, 50` + `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.id ASC LIMIT 0, 50` + // `WHERE download.facilityName = '${mockedSettings.facilityName}' ORDER BY download.userName asc, download.id ASC LIMIT 0, 50` ); }); diff --git a/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.tsx b/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.tsx index f9125908e..6752b35b6 100644 --- a/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.tsx +++ b/packages/datagateway-download/src/downloadStatus/adminDownloadStatusTable.component.tsx @@ -370,9 +370,16 @@ const AdminDownloadStatusTable: React.FC = () => { }, ]} sort={sort} - onSort={(column: string, order: 'desc' | 'asc' | null) => { + onSort={( + column: string, + order: 'desc' | 'asc' | null, + _, + shiftDown?: boolean + ) => { if (order) { - setSort({ ...sort, [column]: order }); + shiftDown + ? setSort({ ...sort, [column]: order }) + : setSort({ [column]: order }); } else { const { [column]: order, ...restOfSort } = sort; setSort(restOfSort); diff --git a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx index 9337fd6b4..a1bf177ba 100644 --- a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx +++ b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx @@ -225,8 +225,8 @@ describe('Download Status Table', () => { // name should be in asc order rows = await screen.findAllByText(/^test-file-\d$/); expect(rows[0]).toHaveTextContent('test-file-1'); - expect(rows[1]).toHaveTextContent('test-file-3'); - expect(rows[2]).toHaveTextContent('test-file-2'); + expect(rows[1]).toHaveTextContent('test-file-2'); + expect(rows[2]).toHaveTextContent('test-file-3'); expect(rows[3]).toHaveTextContent('test-file-4'); expect(rows[4]).toHaveTextContent('test-file-5'); @@ -234,11 +234,11 @@ describe('Download Status Table', () => { // name should be in desc order rows = await screen.findAllByText(/^test-file-\d$/); - expect(rows[0]).toHaveTextContent('test-file-3'); - expect(rows[1]).toHaveTextContent('test-file-1'); - expect(rows[2]).toHaveTextContent('test-file-5'); - expect(rows[3]).toHaveTextContent('test-file-4'); - expect(rows[4]).toHaveTextContent('test-file-2'); + expect(rows[0]).toHaveTextContent('test-file-5'); + expect(rows[1]).toHaveTextContent('test-file-4'); + expect(rows[2]).toHaveTextContent('test-file-3'); + expect(rows[3]).toHaveTextContent('test-file-2'); + expect(rows[4]).toHaveTextContent('test-file-1'); }); it('should filter data when text fields are typed into', async () => { diff --git a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx index 68cafe642..0c8f3c082 100644 --- a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx +++ b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx @@ -326,9 +326,16 @@ const DownloadStatusTable: React.FC = ( }, ]} sort={sort} - onSort={(column: string, order: 'desc' | 'asc' | null) => { + onSort={( + column: string, + order: 'desc' | 'asc' | null, + _, + shiftDown?: boolean + ) => { if (order) { - setSort({ ...sort, [column]: order }); + shiftDown + ? setSort({ ...sort, [column]: order }) + : setSort({ [column]: order }); } else { const { [column]: order, ...restOfSort } = sort; setSort(restOfSort);