mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-26 13:31:45 +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();
|
submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
await apiLogin({ applicationId, password: codeValueMobile });
|
await apiLogin({ applicationId, password: codeValueMobile });
|
||||||
goto('/dashboard');
|
goto('/dashboard');
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
// alert('ApplicationId: ' + applicationId + '; Password: ' + codeValueMobile);
|
// alert('ApplicationId: ' + applicationId + '; Password: ' + codeValueMobile);
|
||||||
}
|
};
|
||||||
|
|
||||||
const onPaste = (e: ClipboardEvent) => {
|
const onPaste = (e: ClipboardEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -65,8 +65,11 @@
|
||||||
codeElementArray[0].focus();
|
codeElementArray[0].focus();
|
||||||
|
|
||||||
// Document on:paste
|
// Document on:paste
|
||||||
document.onpaste = (e: ClipboardEvent) => {
|
document.addEventListener('paste', onPaste);
|
||||||
onPaste(e);
|
|
||||||
|
return () => {
|
||||||
|
// this function is called when the component is destroyed
|
||||||
|
document.removeEventListener('paste', onPaste);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue