Skip to content

Commit

Permalink
fix: améliore le code
Browse files Browse the repository at this point in the history
  • Loading branch information
CopperGiraffe authored Oct 10, 2024
1 parent 7f2d700 commit f6f60b6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/DsfrDataTable/DsfrDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 === undefined ? props.sorted : sortedBy.value
const key = sortedBy.value ?? props.sorted

Check failure on line 68 in src/components/DsfrDataTable/DsfrDataTable.vue

View workflow job for this annotation

GitHub Actions / Run unit tests and CT tests

'sortedBy' was used before it was defined
// @ts-expect-error TS7015
if (((a as DsfrDataTableRow)[key] ?? a) < ((b as DsfrDataTableRow)[key] ?? b)) {
return -1
Expand All @@ -77,7 +77,7 @@ function defaultSortFn (a: string | DsfrDataTableRow, b: string | DsfrDataTableR
return 0
}
const sortedBy = defineModel<string>('sortedBy', { default: undefined })
const sortedBy = defineModel<string | undefined>('sortedBy', { default: undefined })
const sortedDesc = defineModel('sortedDesc', { default: false })
function sortBy (key: string) {
if (!props.sortableRows || (Array.isArray(props.sortableRows) && !props.sortableRows.includes(key))) {
Expand Down

0 comments on commit f6f60b6

Please sign in to comment.