fix: avoid stale event reference in register page retry action

Extract submission logic into submitForm() so the retry toast
action does not capture the original SyntheticEvent, which may
be recycled by React by the time the user clicks retry.

Closes #945
This commit is contained in:
likiosliu 2026-03-25 16:58:46 +08:00
parent a474c4651c
commit e9c51a9fba

View file

@ -43,9 +43,12 @@ export default function RegisterPage() {
}
}, [router]);
const handleSubmit = async (e: React.FormEvent) => {
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
submitForm();
};
const submitForm = async () => {
// Form validation
if (password !== confirmPassword) {
setError({ title: t("password_mismatch"), message: t("passwords_no_match_desc") });
@ -140,7 +143,7 @@ export default function RegisterPage() {
if (shouldRetry(errorCode)) {
toastOptions.action = {
label: tCommon("retry"),
onClick: () => handleSubmit(e),
onClick: () => submitForm(),
};
}