diff --git a/src/components/DsfrDataTable/DsfrDataTable.vue b/src/components/DsfrDataTable/DsfrDataTable.vue index a4b71a58..0c55f9b4 100644 --- a/src/components/DsfrDataTable/DsfrDataTable.vue +++ b/src/components/DsfrDataTable/DsfrDataTable.vue @@ -65,7 +65,7 @@ const lowestLimit = computed(() => currentPage.value * rowsPerPage.value) const highestLimit = computed(() => (currentPage.value + 1) * rowsPerPage.value) function defaultSortFn (a: string | DsfrDataTableRow, b: string | DsfrDataTableRow) { - const key = sortedBy.value + const key = sortedBy.value === undefined ? props.sorted : sortedBy.value // @ts-expect-error TS7015 if (((a as DsfrDataTableRow)[key] ?? a) < ((b as DsfrDataTableRow)[key] ?? b)) { return -1 @@ -77,7 +77,7 @@ function defaultSortFn (a: string | DsfrDataTableRow, b: string | DsfrDataTableR return 0 } -const sortedBy = defineModel('sortedBy', { default: props.sorted }) +const sortedBy = defineModel('sortedBy', { default: undefined }) const sortedDesc = defineModel('sortedDesc', { default: false }) function sortBy (key: string) { if (!props.sortableRows || (Array.isArray(props.sortableRows) && !props.sortableRows.includes(key))) {