Summary
SignUp and ForgotPassword put their server-failure text in react-hook-form's root error and
clear it with clearErrors('root') inside the submit handler. handleSubmit never calls that
handler when the resolver rejects, so a submission that fails client-side validation leaves the
previous server failure on screen next to the fresh field error.
Reproducing
- Sign-up: submit with an email that already exists → the form shows
User already exists above
the submit button (correct).
- Clear the email field, or make it invalid, and submit again.
Please enter a valid email address. appears on the field — and User already exists is still
there, describing an attempt that never left the browser.
ForgotPassword has the same shape (handleSubmit(submitForm) with the clear on the valid path
only), and now has one more root-error source since #1676's client fix routes retryable failures
there.
Why it isn't fixed alongside #1676
SignIn had the same defect and it was fixed there, by hanging the clear off handleSubmit's
second (invalid) argument — but sign-in keeps its failure in component state, not in RHF's root.
The same fix does not work for the RHF-root forms: extending
handleSubmit(submitForm, () => clearErrors('root')) to SignUp was tried and the test failed —
the root error is still rendered after a resolver-rejected resubmit. So these two need a different
mechanism (clear on field change, or move both onto component state the way SignIn now is), which
is a bigger change than that fix warranted and is why it was scoped out by the review's adjudication
rather than bundled in.
Note the repo's own comment at SignUp.tsx asserts the opposite of RHF's documented behaviour here
("handleSubmit reruns the resolver, which only rewrites field errors, so a stale root would
outlive the retry") — worth confirming which is true for the pinned RHF version as part of the fix,
since it determines whether the clear belongs on submit or on change.
Suggested direction
Unify the three auth forms on one mechanism. SignIn's component-state approach is the one with a
working clear-on-invalid story, so moving SignUp and ForgotPassword onto it also removes the
two-patterns-for-three-forms split the #1676 review flagged as an open decision
(signin-error-in-hook-state).
Impact
Cosmetic but confusing: two contradictory messages, one of them stale. No data or security
consequence. Found by the cross-model review on #1676's client fix, adjudicated as pre-existing.
Summary
SignUpandForgotPasswordput their server-failure text in react-hook-form'srooterror andclear it with
clearErrors('root')inside the submit handler.handleSubmitnever calls thathandler when the resolver rejects, so a submission that fails client-side validation leaves the
previous server failure on screen next to the fresh field error.
Reproducing
User already existsabovethe submit button (correct).
Please enter a valid email address.appears on the field — andUser already existsis stillthere, describing an attempt that never left the browser.
ForgotPasswordhas the same shape (handleSubmit(submitForm)with the clear on the valid pathonly), and now has one more root-error source since #1676's client fix routes retryable failures
there.
Why it isn't fixed alongside #1676
SignInhad the same defect and it was fixed there, by hanging the clear offhandleSubmit'ssecond (invalid) argument — but sign-in keeps its failure in component state, not in RHF's
root.The same fix does not work for the RHF-root forms: extending
handleSubmit(submitForm, () => clearErrors('root'))toSignUpwas tried and the test failed —the root error is still rendered after a resolver-rejected resubmit. So these two need a different
mechanism (clear on field change, or move both onto component state the way
SignInnow is), whichis a bigger change than that fix warranted and is why it was scoped out by the review's adjudication
rather than bundled in.
Note the repo's own comment at
SignUp.tsxasserts the opposite of RHF's documented behaviour here("
handleSubmitreruns the resolver, which only rewrites field errors, so a stalerootwouldoutlive the retry") — worth confirming which is true for the pinned RHF version as part of the fix,
since it determines whether the clear belongs on submit or on change.
Suggested direction
Unify the three auth forms on one mechanism.
SignIn's component-state approach is the one with aworking clear-on-invalid story, so moving
SignUpandForgotPasswordonto it also removes thetwo-patterns-for-three-forms split the #1676 review flagged as an open decision
(
signin-error-in-hook-state).Impact
Cosmetic but confusing: two contradictory messages, one of them stale. No data or security
consequence. Found by the cross-model review on #1676's client fix, adjudicated as pre-existing.