Skip to content

Commit ed18fff

Browse files
committed
🐛 Fix lume-tooltip use v-if instead of v-show
1 parent 5a0c3d1 commit ed18fff

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/lib/src/components/core/lume-tooltip/lume-tooltip.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div
3-
v-show="opened && targetElement"
3+
v-if="opened && targetElement"
44
ref="root"
55
class="lume-tooltip lume-typography--caption"
66
:class="{
@@ -66,6 +66,7 @@ interface TooltipItem {
6666
<script setup lang="ts">
6767
import {
6868
computed,
69+
nextTick,
6970
onBeforeUnmount,
7071
onMounted,
7172
PropType,
@@ -214,14 +215,15 @@ function destroyPopper() {
214215
if (popper.value) {
215216
popper.value.destroy();
216217
emit('closed');
217-
root.value.classList.remove('lume-tooltip--animated'); // Remove transition class
218+
219+
root.value && root.value.classList.remove('lume-tooltip--animated'); // Remove transition class
218220
}
219221
}
220222
221223
function updatePopper() {
222224
if (!popper.value) return;
223225
224-
if (allOptions.value.withAnimation !== false) {
226+
if (allOptions.value.withAnimation !== false && root.value) {
225227
root.value.classList.add('lume-tooltip--animated'); // Add transition class
226228
}
227229
@@ -237,9 +239,11 @@ function updatePopper() {
237239
// Watchers
238240
watch(
239241
() => props.targetElement,
240-
(newValue, oldValue) => {
241-
if (!oldValue && newValue) initPopper();
242-
else updatePopper();
242+
async (newValue, oldValue) => {
243+
if (!oldValue && newValue) {
244+
await nextTick(); // wait for `root` to be picked up
245+
initPopper();
246+
} else updatePopper();
243247
}
244248
);
245249

0 commit comments

Comments
 (0)