From 7f2d7003413ee426e6defc67c5df3823f7d7ad3f Mon Sep 17 00:00:00 2001 From: CopperGiraffe Date: Thu, 10 Oct 2024 16:01:26 +0200 Subject: [PATCH] fix: correction de code sur la valeur initiale du sortedBy --- src/components/DsfrDataTable/DsfrDataTable.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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))) {