fix: remove paste event handler on unmount

This commit is contained in:
EETagent 2022-12-04 12:21:55 +01:00
parent 0516bf2a1a
commit f58d8bb01f

View file

@ -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>