diff --git a/website/src/components/SearchPage/SearchFullUI.tsx b/website/src/components/SearchPage/SearchFullUI.tsx index 07996ed8db..f76e6f9d37 100644 --- a/website/src/components/SearchPage/SearchFullUI.tsx +++ b/website/src/components/SearchPage/SearchFullUI.tsx @@ -82,8 +82,8 @@ export const InnerSearchFullUI = ({ const [state, setState] = useQueryAsState({}); const [page, setPage] = useState(1); - const orderByField = state.orderBy ?? schema.primaryKey; - const orderDirection = state.order ?? 'ascending'; + const orderByField = state.orderBy ?? schema.defaultOrderBy ?? schema.primaryKey; + const orderDirection = state.order ?? schema.defaultOrder ?? 'ascending'; const setOrderByField = (field: string) => { setState((prev: QueryState) => ({ diff --git a/website/src/components/SequenceDetailsPage/getTableData.spec.ts b/website/src/components/SequenceDetailsPage/getTableData.spec.ts index 41103bc693..13c6315847 100644 --- a/website/src/components/SequenceDetailsPage/getTableData.spec.ts +++ b/website/src/components/SequenceDetailsPage/getTableData.spec.ts @@ -76,35 +76,8 @@ describe('getTableData', () => { test('should return default values when there is no data', async () => { const result = await getTableData(accessionVersion, schema, lapisClient); - const defaultList: TableDataEntry[] = [ - { - label: 'Metadata field1', - name: 'metadataField1', - value: 'N/A', - customDisplay: undefined, - header: 'testHeader1', - type: { kind: 'metadata', metadataType: 'string' }, - }, - { - label: 'Metadata field2', - name: 'metadataField2', - value: 'N/A', - customDisplay: undefined, - header: '', - type: { kind: 'metadata', metadataType: 'string' }, - }, - { - label: 'Timestamp field', - name: 'timestampField', - value: 'N/A', - customDisplay: undefined, - header: '', - type: { kind: 'metadata', metadataType: 'timestamp' }, - }, - ]; - const data = result._unsafeUnwrap().data; - expect(data).toStrictEqual(defaultList.concat(defaultMutationsInsertionsDeletionsList)); + expect(data).toStrictEqual(defaultMutationsInsertionsDeletionsList); }); test('should return details field values', async () => { diff --git a/website/src/components/SequenceDetailsPage/getTableData.ts b/website/src/components/SequenceDetailsPage/getTableData.ts index f0ea5c6626..a93c43f41c 100644 --- a/website/src/components/SequenceDetailsPage/getTableData.ts +++ b/website/src/components/SequenceDetailsPage/getTableData.ts @@ -160,6 +160,7 @@ function toTableData(config: Schema) { }): TableDataEntry[] => { const data: TableDataEntry[] = config.metadata .filter((metadata) => metadata.hideOnSequenceDetailsPage !== true) + .filter((metadata) => details[metadata.name] !== null && metadata.name in details) .map((metadata) => ({ label: metadata.displayName ?? sentenceCase(metadata.name), name: metadata.name,