Skip to content

Commit c0b7d7b

Browse files
committed
fix(VTreeview): activatable implies openOnClick=false
1 parent 5c7f029 commit c0b7d7b

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

packages/vuetify/src/components/VTreeview/VTreeviewChildren.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { makeDensityProps } from '@/composables/density'
88
import { IconValue } from '@/composables/icons'
99

1010
// Utilities
11-
import { computed, reactive, ref, toRaw } from 'vue'
11+
import { computed, mergeProps, reactive, ref, toRaw } from 'vue'
1212
import { genericComponent, propsFactory } from '@/util'
1313

1414
// Types
@@ -51,6 +51,7 @@ export const makeVTreeviewChildrenProps = propsFactory({
5151
falseIcon: IconValue,
5252
trueIcon: IconValue,
5353
returnObject: Boolean,
54+
activatable: Boolean,
5455
selectable: Boolean,
5556
selectedColor: String,
5657
selectStrategy: [String, Function, Object] as PropType<SelectStrategyProp>,
@@ -80,7 +81,7 @@ export const VTreeviewChildren = genericComponent<new <T extends InternalListIte
8081
!props.disabled && (
8182
props.openOnClick != null
8283
? props.openOnClick
83-
: props.selectable
84+
: props.selectable && !props.activatable
8485
)))
8586

8687
async function checkChildren (item: InternalListItem) {

packages/vuetify/src/components/VTreeview/VTreeviewItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { IconValue } from '@/composables/icons'
1313

1414
// Utilities
1515
import { computed, inject, ref, toRaw } from 'vue'
16-
import { genericComponent, omit, propsFactory, useRender } from '@/util'
16+
import { genericComponent, propsFactory, useRender } from '@/util'
1717

1818
// Types
1919
import { VTreeviewSymbol } from './shared'
@@ -68,7 +68,7 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
6868
}
6969

7070
useRender(() => {
71-
const listItemProps = omit(VListItem.filterProps(props), ['onClick'])
71+
const listItemProps = VListItem.filterProps(props)
7272
const hasPrepend = slots.prepend || props.toggleIcon
7373

7474
return (
@@ -85,7 +85,7 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
8585
props.class,
8686
]}
8787
ripple={ false }
88-
onClick={ props.onClick ?? activateGroupActivator }
88+
onClick={ activateGroupActivator }
8989
>
9090
{{
9191
...slots,

packages/vuetify/src/components/VTreeview/__tests__/VTreeview.spec.browser.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe.each([
7676
/>
7777
))
7878

79-
await userEvent.click(screen.getByText(/Human Resources/))
79+
await userEvent.click(screen.getByText(/Administrators/))
8080
expect(activated.value).toStrictEqual([])
8181

8282
await userEvent.click(screen.getByText(/John/))
@@ -98,7 +98,7 @@ describe.each([
9898
/>
9999
))
100100

101-
await userEvent.click(screen.getByText(/Human Resources/))
101+
await userEvent.click(screen.getByText(/Administrators/))
102102
expect(activated.value).toStrictEqual([])
103103

104104
await userEvent.click(screen.getByText(/John/))
@@ -120,16 +120,16 @@ describe.each([
120120
/>
121121
))
122122

123-
await userEvent.click(screen.getByText(/Human Resources/))
124-
expect(activated.value).toStrictEqual([1])
125-
126-
await userEvent.click(screen.getByText(/Core team/))
127-
expect(activated.value).toStrictEqual([1, 2])
123+
await userEvent.click(screen.getByText(/Administrators/))
124+
expect(activated.value).toStrictEqual([3])
128125

129126
await userEvent.click(screen.getByText(/John/))
130127
await userEvent.click(screen.getByText(/Kael/))
131128
await userEvent.click(screen.getByText(/Nekosaur/))
132-
expect(activated.value).toStrictEqual([1, 2, 201, 202, 203])
129+
expect(activated.value).toStrictEqual([3, 201, 202, 203])
130+
131+
await userEvent.click(screen.getByText(/Core team/))
132+
expect(activated.value).toStrictEqual([3, 201, 202, 203, 2])
133133
})
134134

135135
it('single-independent strategy', async () => {
@@ -145,16 +145,16 @@ describe.each([
145145
/>
146146
))
147147

148-
await userEvent.click(screen.getByText(/Human Resources/))
149-
expect(activated.value).toStrictEqual([1])
150-
151-
await userEvent.click(screen.getByText(/Core team/))
152-
expect(activated.value).toStrictEqual([2])
148+
await userEvent.click(screen.getByText(/Administrators/))
149+
expect(activated.value).toStrictEqual([3])
153150

154151
await userEvent.click(screen.getByText(/John/))
155152
await userEvent.click(screen.getByText(/Kael/))
156153
await userEvent.click(screen.getByText(/Nekosaur/))
157154
expect(activated.value).toStrictEqual([203])
155+
156+
await userEvent.click(screen.getByText(/Core team/))
157+
expect(activated.value).toStrictEqual([2])
158158
})
159159

160160
// https://github.com/vuetifyjs/vuetify/issues/20665

0 commit comments

Comments
 (0)