|
2 | 2 | import { useProxiedModel } from '@/composables/proxiedModel'
|
3 | 3 |
|
4 | 4 | // Utilities
|
5 |
| -import { inject, provide, toRef } from 'vue' |
6 |
| -import { isObject, propsFactory } from '@/util' |
| 5 | +import { inject, provide, toRaw, toRef } from 'vue' |
| 6 | +import { propsFactory } from '@/util' |
7 | 7 |
|
8 | 8 | // Types
|
9 | 9 | import type { InjectionKey, PropType, Ref } from 'vue'
|
@@ -40,24 +40,23 @@ export function provideExpanded (props: ExpandProps) {
|
40 | 40 | return [...v.values()]
|
41 | 41 | })
|
42 | 42 |
|
43 |
| - function getItemKey (item: DataTableItem) { |
44 |
| - return isObject(item.value) ? item.key : item.value |
45 |
| - } |
46 |
| - |
47 | 43 | function expand (item: DataTableItem, value: boolean) {
|
48 | 44 | const newExpanded = new Set(expanded.value)
|
| 45 | + const rawValue = toRaw(item.value) |
49 | 46 |
|
50 | 47 | if (!value) {
|
51 |
| - newExpanded.delete(getItemKey(item)) |
| 48 | + const item = [...expanded.value].find(x => toRaw(x) === rawValue)! |
| 49 | + newExpanded.delete(item) |
52 | 50 | } else {
|
53 |
| - newExpanded.add(getItemKey(item)) |
| 51 | + newExpanded.add(rawValue) |
54 | 52 | }
|
55 | 53 |
|
56 | 54 | expanded.value = newExpanded
|
57 | 55 | }
|
58 | 56 |
|
59 | 57 | function isExpanded (item: DataTableItem) {
|
60 |
| - return expanded.value.has(getItemKey(item)) |
| 58 | + const rawValue = toRaw(item.value) |
| 59 | + return [...expanded.value].some(x => toRaw(x) === rawValue) |
61 | 60 | }
|
62 | 61 |
|
63 | 62 | function toggleExpand (item: DataTableItem) {
|
|
0 commit comments