mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
fix: remove paste event handler on unmount
This commit is contained in:
parent
0516bf2a1a
commit
f58d8bb01f
1 changed files with 7 additions and 4 deletions
|
|
@ -40,7 +40,7 @@
|
|||
submit();
|
||||
}
|
||||
|
||||
const submit = async () => {
|
||||
const submit = async () => {
|
||||
try {
|
||||
await apiLogin({ applicationId, password: codeValueMobile });
|
||||
goto('/dashboard');
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
console.error(e);
|
||||
}
|
||||
// alert('ApplicationId: ' + applicationId + '; Password: ' + codeValueMobile);
|
||||
}
|
||||
};
|
||||
|
||||
const onPaste = (e: ClipboardEvent) => {
|
||||
e.preventDefault();
|
||||
|
|
@ -65,8 +65,11 @@
|
|||
codeElementArray[0].focus();
|
||||
|
||||
// Document on:paste
|
||||
document.onpaste = (e: ClipboardEvent) => {
|
||||
onPaste(e);
|
||||
document.addEventListener('paste', onPaste);
|
||||
|
||||
return () => {
|
||||
// this function is called when the component is destroyed
|
||||
document.removeEventListener('paste', onPaste);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue