fix: send code button behavior on enter key press (#1121)
This commit is contained in:
parent
def391cb76
commit
74329a49cc
1 changed files with 19 additions and 0 deletions
|
|
@ -88,6 +88,25 @@ export const EmailCodeForm = ({ onSuccess }: any) => {
|
||||||
setErrorResendingCode(false);
|
setErrorResendingCode(false);
|
||||||
}, [emailOld]);
|
}, [emailOld]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const submitForm = (e: KeyboardEvent) => {
|
||||||
|
if (!codeSent && e.key === "Enter") {
|
||||||
|
e.preventDefault();
|
||||||
|
handleSubmit(onSubmit)().then(() => {
|
||||||
|
setResendCodeTimer(30);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!codeSent) {
|
||||||
|
window.addEventListener("keydown", submitForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("keydown", submitForm);
|
||||||
|
};
|
||||||
|
}, [handleSubmit, codeSent]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<form className="space-y-5 py-5 px-5">
|
<form className="space-y-5 py-5 px-5">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue