Skip to content

Commit

Permalink
fix: tooltip popover trigger issue
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Sep 19, 2023
1 parent 0bc0dcb commit e9634a9
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion apps/www/src/lib/registry/default/example/SliderDemo.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { ref } from 'vue'
import { cn } from '@/lib/utils'
import { Slider } from '@/lib/registry/default/ui/slider'
const modelValue = [50]
const modelValue = ref([50])
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const props = defineProps<PopoverTriggerProps>()
</script>

<template>
<PopoverTrigger v-bind="props">
<PopoverTrigger v-bind="props" class="">
<slot />
</PopoverTrigger>
</template>
4 changes: 3 additions & 1 deletion apps/www/src/lib/registry/default/ui/slider/Slider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { cn, useEmitAsProps } from '@/lib/utils'
const props = defineProps<SliderRootProps>()
const emits = defineEmits<SliderRootEmits>()
const emitsAsProps = useEmitAsProps(emits)
</script>

<template>
Expand All @@ -13,7 +15,7 @@ const emits = defineEmits<SliderRootEmits>()
'relative flex w-full touch-none select-none items-center',
$attrs.class ?? '',
)"
v-bind="{ ...props, ...useEmitAsProps(emits) }"
v-bind="{ ...props, ...emitsAsProps }"
>
<SliderTrack class="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
<SliderRange class="absolute h-full bg-primary" />
Expand Down
4 changes: 3 additions & 1 deletion apps/www/src/lib/registry/default/ui/tooltip/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { useEmitAsProps } from '@/lib/utils'
const props = defineProps<TooltipRootProps>()
const emits = defineEmits<TooltipRootEmits>()
const emitsAsProps = useEmitAsProps(emits)
</script>

<template>
<TooltipRoot v-bind="{ ...props, ...useEmitAsProps(emits) }">
<TooltipRoot v-bind="{ ...props, ...emitsAsProps }">
<slot />
</TooltipRoot>
</template>
12 changes: 8 additions & 4 deletions apps/www/src/lib/registry/default/ui/tooltip/TooltipContent.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<script setup lang="ts">
import { TooltipContent, type TooltipContentEmits, type TooltipContentProps } from 'radix-vue'
import { TooltipContent, type TooltipContentEmits, type TooltipContentProps, TooltipPortal } from 'radix-vue'
import { cn, useEmitAsProps } from '@/lib/utils'
const props = withDefaults(defineProps<TooltipContentProps>(), {
sideOffset: 4,
})
const emits = defineEmits<TooltipContentEmits>()
const emitsAsProps = useEmitAsProps(emits)
</script>

<template>
<TooltipContent v-bind="{ ...props, ...useEmitAsProps(emits) }" :class="cn('z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', $attrs.class ?? '')">
<slot />
</TooltipContent>
<TooltipPortal>
<TooltipContent v-bind="{ ...props, ...emitsAsProps, ...$attrs }" :class="cn('z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', $attrs.class ?? '')">
<slot />
</TooltipContent>
</TooltipPortal>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const props = defineProps<TooltipTriggerProps>()
</script>

<template>
<TooltipTrigger v-bind="props">
<TooltipTrigger v-bind="props" class="">
<slot />
</TooltipTrigger>
</template>
3 changes: 2 additions & 1 deletion apps/www/src/lib/registry/new-york/example/SliderDemo.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script setup lang="ts">
import { ref } from 'vue'
import { cn } from '@/lib/utils'
import { Slider } from '@/lib/registry/new-york/ui/slider'
const modelValue = [50]
const modelValue = ref([50])
</script>

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const props = defineProps<PopoverTriggerProps>()
</script>

<template>
<PopoverTrigger v-bind="props">
<PopoverTrigger v-bind="props" class="">
<slot />
</PopoverTrigger>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const props = defineProps<TooltipTriggerProps>()
</script>

<template>
<TooltipTrigger v-bind="props">
<TooltipTrigger v-bind="props" class="">
<slot />
</TooltipTrigger>
</template>

0 comments on commit e9634a9

Please sign in to comment.