From 4d65db678b0dfe1b4e443d61ae07d1f235c014c3 Mon Sep 17 00:00:00 2001 From: Kael Date: Tue, 26 Sep 2023 00:02:09 +1000 Subject: [PATCH] fix(VDataTable): strip item value proxies in selected Set Object values result in different Proxy objects when adding to the set vs checking Set.has() --- .../src/labs/VDataTable/composables/select.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/vuetify/src/labs/VDataTable/composables/select.ts b/packages/vuetify/src/labs/VDataTable/composables/select.ts index 1895e505725..f18623624b4 100644 --- a/packages/vuetify/src/labs/VDataTable/composables/select.ts +++ b/packages/vuetify/src/labs/VDataTable/composables/select.ts @@ -2,7 +2,7 @@ import { useProxiedModel } from '@/composables/proxiedModel' // Utilities -import { computed, inject, provide } from 'vue' +import { computed, inject, provide, toRaw } from 'vue' import { deepEqual, propsFactory, wrapInArray } from '@/util' // Types @@ -44,7 +44,7 @@ const singleSelectStrategy: DataTableSelectStrategy = { showSelectAll: false, allSelected: () => [], select: ({ items, value }) => { - return new Set(value ? [items[0]?.value] : []) + return new Set(value ? [toRaw(items[0]?.value)] : []) }, selectAll: ({ selected }) => selected, } @@ -54,8 +54,8 @@ const pageSelectStrategy: DataTableSelectStrategy = { allSelected: ({ currentPage }) => currentPage, select: ({ items, value, selected }) => { for (const item of items) { - if (value) selected.add(item.value) - else selected.delete(item.value) + if (value) selected.add(toRaw(item.value)) + else selected.delete(toRaw(item.value)) } return selected @@ -68,8 +68,8 @@ const allSelectStrategy: DataTableSelectStrategy = { allSelected: ({ allItems }) => allItems, select: ({ items, value, selected }) => { for (const item of items) { - if (value) selected.add(item.value) - else selected.delete(item.value) + if (value) selected.add(toRaw(item.value)) + else selected.delete(toRaw(item.value)) } return selected @@ -122,11 +122,11 @@ export function provideSelection ( }) function isSelected (items: SelectableItem | SelectableItem[]) { - return wrapInArray(items).every(item => selected.value.has(item.value)) + return wrapInArray(items).every(item => selected.value.has(toRaw(item.value))) } function isSomeSelected (items: SelectableItem | SelectableItem[]) { - return wrapInArray(items).some(item => selected.value.has(item.value)) + return wrapInArray(items).some(item => selected.value.has(toRaw(item.value))) } function select (items: SelectableItem[], value: boolean) {