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 1
1
<script setup lang="ts">
2
2
import { Tippy , TippyComponent } from " vue-tippy" ;
3
- import { useTemplateRef } from " vue" ;
3
+ import { ref , useTemplateRef , watch } from " vue" ;
4
4
5
5
const props = withDefaults (
6
6
defineProps <{
@@ -11,14 +11,16 @@ const props = withDefaults(
11
11
);
12
12
13
13
const tippyRef = useTemplateRef <TippyComponent | null >(" tippyRef" );
14
- let timeoutId: number ;
14
+ const timeoutId = ref ( 0 ) ;
15
15
16
16
async function copyToClipboard() {
17
17
await navigator .clipboard .writeText (props .value );
18
- window . clearTimeout ( timeoutId );
18
+
19
19
tippyRef .value ?.show ();
20
- timeoutId = window .setTimeout (() => tippyRef .value ?.hide (), 3000 );
20
+ timeoutId . value = window .setTimeout (() => tippyRef .value ?.hide (), 3000 );
21
21
}
22
+
23
+ watch (timeoutId , (_ , previousTimeoutId ) => window .clearTimeout (previousTimeoutId ));
22
24
</script >
23
25
24
26
<template >
You can’t perform that action at this time.
0 commit comments