From 32e5747c1a46823fec09c371912415072e12de25 Mon Sep 17 00:00:00 2001 From: Yash Kumar Date: Sun, 16 Feb 2025 19:29:09 -0800 Subject: [PATCH] fix(DataTable): allow removal of additional sortings (#20990) fixes #20985 --- .../src/components/VDataTable/composables/sort.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/vuetify/src/components/VDataTable/composables/sort.ts b/packages/vuetify/src/components/VDataTable/composables/sort.ts index 03581dac81f..42f2acdfea3 100644 --- a/packages/vuetify/src/components/VDataTable/composables/sort.ts +++ b/packages/vuetify/src/components/VDataTable/composables/sort.ts @@ -59,10 +59,13 @@ export function provideSort (options: { const item = newSortBy.find(x => x.key === column.key) if (!item) { - if (multiSort.value) newSortBy = [...newSortBy, { key: column.key, order: 'asc' }] - else newSortBy = [{ key: column.key, order: 'asc' }] + if (multiSort.value) { + newSortBy.push({ key: column.key, order: 'asc' }) + } else { + newSortBy = [{ key: column.key, order: 'asc' }] + } } else if (item.order === 'desc') { - if (mustSort.value) { + if (mustSort.value && newSortBy.length === 1) { item.order = 'asc' } else { newSortBy = newSortBy.filter(x => x.key !== column.key)