Skip to content

Commit

Permalink
fix(VDataTable): strip item value proxies in selected Set
Browse files Browse the repository at this point in the history
Object values result in different Proxy objects when adding to the set vs checking Set.has()
  • Loading branch information
KaelWD committed Sep 25, 2023
1 parent 3759243 commit 4d65db6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/vuetify/src/labs/VDataTable/composables/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4d65db6

Please sign in to comment.