Fixed useTooltip for elements that already exist at setup
ci/woodpecker/push/ociImagePush Pipeline is running
Details
ci/woodpecker/push/ociImagePush Pipeline is running
Details
This commit is contained in:
parent
812d4ee6b2
commit
d12b65fff7
|
@ -66,15 +66,9 @@ export function useTooltip(
|
|||
close();
|
||||
};
|
||||
|
||||
const stop = watch(
|
||||
elRef,
|
||||
() => {
|
||||
if (elRef.value) {
|
||||
stop();
|
||||
const addListeners = () => {
|
||||
const el =
|
||||
elRef.value instanceof Element
|
||||
? elRef.value
|
||||
: elRef.value.$el;
|
||||
elRef.value instanceof Element ? elRef.value : elRef.value!.$el;
|
||||
el.addEventListener("mouseover", onMouseover, {
|
||||
passive: true,
|
||||
});
|
||||
|
@ -86,13 +80,25 @@ export function useTooltip(
|
|||
});
|
||||
el.addEventListener("touchend", onTouchend, { passive: true });
|
||||
el.addEventListener("click", close, { passive: true });
|
||||
};
|
||||
|
||||
// Can't use immediate, because of the self-reference of the watch stop handle
|
||||
if (elRef.value) {
|
||||
addListeners();
|
||||
} else {
|
||||
const stop = watch(
|
||||
elRef,
|
||||
() => {
|
||||
if (elRef.value) {
|
||||
stop();
|
||||
addListeners();
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
flush: "post",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
close();
|
||||
|
|
Loading…
Reference in New Issue