File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
src/Frontend/src/components Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change 11<script setup lang="ts">
22import { Tippy , TippyComponent } from " vue-tippy" ;
3- import { useTemplateRef } from " vue" ;
3+ import { ref , useTemplateRef , watch } from " vue" ;
44
55const props = withDefaults (
66 defineProps <{
@@ -11,14 +11,16 @@ const props = withDefaults(
1111);
1212
1313const tippyRef = useTemplateRef <TippyComponent | null >(" tippyRef" );
14- let timeoutId: number ;
14+ const timeoutId = ref ( 0 ) ;
1515
1616async function copyToClipboard() {
1717 await navigator .clipboard .writeText (props .value );
18- window . clearTimeout ( timeoutId );
18+
1919 tippyRef .value ?.show ();
20- timeoutId = window .setTimeout (() => tippyRef .value ?.hide (), 3000 );
20+ timeoutId . value = window .setTimeout (() => tippyRef .value ?.hide (), 3000 );
2121}
22+
23+ watch (timeoutId , (_ , previousTimeoutId ) => window .clearTimeout (previousTimeoutId ));
2224 </script >
2325
2426<template >
You can’t perform that action at this time.
0 commit comments