Skip to content

Commit a9b6fa2

Browse files
committed
Atoms - Tooltip - Use teleport component
1 parent f882b3e commit a9b6fa2

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/atoms/Tooltip.vue

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,16 @@ const props = defineProps({
6060
blockShiftY: {
6161
type: Boolean,
6262
default: false,
63+
},
64+
isFullscreen: {
65+
type: Boolean,
66+
default: false
6367
}
6468
});
6569
6670
const tooltip = ref(null)
6771
68-
const clientPosition = ref(useMouse());
72+
const clientPosition = ref(useMouse(props.parent));
6973
7074
const position = computed(() => {
7175
return calcTooltipPosition({
@@ -85,18 +89,20 @@ const convertedBackground = computed(() => {
8589
</script>
8690

8791
<template>
88-
<div
89-
ref="tooltip"
90-
data-cy="tooltip"
91-
:class="{'vue-data-ui-custom-tooltip' : isCustom, 'vue-data-ui-tooltip': !isCustom}"
92-
v-if="show"
93-
:style="`pointer-events:none;top:${position.top}px;left:${position.left}px;${isCustom ? '' : `background:${convertedBackground};color:${color};max-width:${maxWidth};font-size:${fontSize}px`};border-radius:${borderRadius}px;border:${borderWidth}px solid ${borderColor};`"
94-
>
95-
<slot name="tooltip-before"/>
96-
<slot/>
97-
<div v-html="content"/>
98-
<slot name="tooltip-after"/>
99-
</div>
92+
<teleport :to="isFullscreen ? parent : 'body'">
93+
<div
94+
ref="tooltip"
95+
data-cy="tooltip"
96+
:class="{'vue-data-ui-custom-tooltip' : isCustom, 'vue-data-ui-tooltip': !isCustom}"
97+
v-if="show"
98+
:style="`pointer-events:none;top:${position.top}px;left:${position.left}px;${isCustom ? '' : `background:${convertedBackground};color:${color};max-width:${maxWidth};font-size:${fontSize}px`};border-radius:${borderRadius}px;border:${borderWidth}px solid ${borderColor};`"
99+
>
100+
<slot name="tooltip-before"/>
101+
<slot/>
102+
<div v-html="content"/>
103+
<slot name="tooltip-after"/>
104+
</div>
105+
</teleport>
100106
</template>
101107

102108
<style>

0 commit comments

Comments
 (0)