@@ -8,7 +8,7 @@ import { makeDensityProps } from '@/composables/density'
8
8
import { IconValue } from '@/composables/icons'
9
9
10
10
// Utilities
11
- import { computed , reactive , toRaw } from 'vue'
11
+ import { computed , reactive , ref , toRaw } from 'vue'
12
12
import { genericComponent , propsFactory } from '@/util'
13
13
14
14
// Types
@@ -74,8 +74,14 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
74
74
75
75
setup ( props , { slots } ) {
76
76
const isLoading = reactive ( new Set < unknown > ( ) )
77
+ const activatorItems = ref < VTreeviewItem [ ] > ( [ ] )
77
78
78
- const isClickOnOpen = computed ( ( ) => ! props . disabled && ( props . openOnClick != null ? props . openOnClick : props . selectable ) )
79
+ const isClickOnOpen = computed ( ( ) => (
80
+ ! props . disabled && (
81
+ props . openOnClick != null
82
+ ? props . openOnClick
83
+ : props . selectable
84
+ ) ) )
79
85
80
86
async function checkChildren ( item : InternalListItem ) {
81
87
try {
@@ -161,11 +167,14 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
161
167
...activatorProps ,
162
168
value : itemProps ?. value ,
163
169
onToggleExpand : [ ( ) => checkChildren ( item ) , activatorProps . onClick ] as any ,
164
- onClick : isClickOnOpen . value ? [ ( ) => checkChildren ( item ) , activatorProps . onClick ] as any : undefined ,
170
+ onClick : isClickOnOpen . value
171
+ ? [ ( ) => checkChildren ( item ) , activatorProps . onClick ] as any
172
+ : ( ) => selectItem ( activatorItems . value [ index ] ?. select , ! activatorItems . value [ index ] ?. isSelected ) ,
165
173
}
166
174
167
175
return (
168
176
< VTreeviewItem
177
+ ref = { el => activatorItems . value [ index ] = el as VTreeviewItem }
169
178
{ ...listItemProps }
170
179
value = { props . returnObject ? item . raw : itemProps . value }
171
180
loading = { loading }
0 commit comments