Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TooltipTrigger): open tooltip on touch devices #1474

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions packages/radix-vue/src/Tooltip/TooltipTrigger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,21 @@ onMounted(() => {
function handlePointerUp() {
setTimeout(() => {
isPointerDown.value = false
}, 1)
}, 100)
}

function handlePointerDown() {
function handlePointerDown(e: PointerEvent) {
if (e.pointerType === 'mouse')
return

isPointerDown.value = true
document.addEventListener('pointerup', handlePointerUp, { once: true })
}

function handlePointerMove(event: PointerEvent) {
if (event.pointerType === 'touch')
return

if (
!hasPointerMoveOpened.value && !providerContext.isPointerInTransitRef.value
) {
Expand All @@ -72,7 +76,10 @@ function handlePointerMove(event: PointerEvent) {
}
}

function handlePointerLeave() {
function handlePointerLeave(event: PointerEvent) {
if (event.pointerType === 'touch')
return

rootContext.onTriggerLeave()
hasPointerMoveOpened.value = false
}
Expand All @@ -92,6 +99,9 @@ function handleBlur() {
}

function handleClick() {
if (isPointerDown.value)
return rootContext.onOpen()

if (!rootContext.disableClosingTrigger.value)
rootContext.onClose()
}
Expand Down