Skip to content

Commit

Permalink
chore(VDataTable): add additional check for customResult = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
KaelWD committed Apr 15, 2024
1 parent b4ebc6f commit 3889a80
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/vuetify/src/components/VDataTable/composables/sort.ts
Expand Up @@ -125,6 +125,7 @@ export function sortItems<T extends Record<string, any>> (

return [...items].sort((a, b) => {
for (let i = 0; i < sortByItems.length; i++) {
let hasCustomResult = false
const sortKey = sortByItems[i].key
const sortOrder = sortByItems[i].order ?? 'asc'

Expand All @@ -144,18 +145,20 @@ export function sortItems<T extends Record<string, any>> (
const customResult = customRawSorters[sortKey](sortARaw, sortBRaw)

if (customResult == null) continue

return customResult
hasCustomResult = true
if (customResult) return customResult
}

if (customSorters?.[sortKey]) {
const customResult = customSorters[sortKey](sortA, sortB)

if (customResult == null) continue

return customResult
hasCustomResult = true
if (customResult) return customResult
}

if (hasCustomResult) continue

// Dates should be compared numerically
if (sortA instanceof Date && sortB instanceof Date) {
return sortA.getTime() - sortB.getTime()
Expand Down

0 comments on commit 3889a80

Please sign in to comment.