Skip to content

Commit

Permalink
chore: fix known issue & improve
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwu9145 committed May 12, 2024
1 parent 7f3811a commit 52385b1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/vuetify/src/labs/VTreeview/VTreeviewItem.tsx
Expand Up @@ -50,7 +50,11 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
root,
} = useNestedItem(id, false)

const isActivetableGroupActivator = computed(() => (root.activatable || root.selectable) && isGroupActivator && !props.openOnClick)
const isActivetableGroupActivator = computed(() =>
(root.activatable.value || root.selectable.value) &&
isGroupActivator &&
!props.openOnClick
)

const { densityClasses } = useDensity(props, 'v-list-item')

Expand All @@ -67,8 +71,11 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
(props.link || link.isClickable.value || (props.value != null && !!vListItemRef.value?.list))
)

function onClick (e: MouseEvent | KeyboardEvent) {
if (!isActivetableGroupActivator.value && isGroupActivator) return
function selectItem (e: MouseEvent | KeyboardEvent) {
if (
!isClickable.value ||
(!isActivetableGroupActivator.value && isGroupActivator)
) return

if (root.activatable.value) {
if (isActivetableGroupActivator.value) {
Expand All @@ -88,7 +95,7 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
function onKeyDown (e: KeyboardEvent) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
onClick(e as any as MouseEvent)
selectItem(e)
}
}

Expand All @@ -115,7 +122,7 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
densityClasses.value,
props.class,
]}
onClick={ onClick }
onClick={ selectItem }
v-ripple={ isClickable.value && props.ripple }
>
<>
Expand Down Expand Up @@ -173,7 +180,7 @@ export const VTreeviewItem = genericComponent<VListItemSlots>()({
},
props.class,
]}
onClick={ onClick }
onClick={ selectItem }
onKeydown={ isClickable.value && onKeyDown }
>
{{
Expand Down

0 comments on commit 52385b1

Please sign in to comment.