The bug is almost certainly two submit paths: a <button type="submit"> inside a <form onSubmit> and an onKeyDown handler that calls submit on Enter. Enter triggers both.
Remove the key handler, the form already submits on Enter:
<form onSubmit={handleSubmit}>
<input name="email" />
<button type="submit">Save</button>
</form>For the Cursor loop: select only the onKeyDown lines and ask "why does this fire together with onSubmit?" A question about cause gets a smaller answer than "fix this".