Skip to content

Use React Router Form for save-changes submission - #44

Open
tayloraj10 wants to merge 1 commit into
mainfrom
update-forms
Open

Use React Router Form for save-changes submission#44
tayloraj10 wants to merge 1 commit into
mainfrom
update-forms

Conversation

@tayloraj10

@tayloraj10 tayloraj10 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Use React Router Form for save-changes submission

Problem

The "Save changes" button on the review detail page was a plain <Button onClick={...}>, unlike the approve/reject buttons on the same page which already use <Form>. This inconsistency meant "Save changes" lacked proper submit semantics (Enter-to-submit, pending state via native form submission, progressive enhancement). Separately, the logout route performed its sign-out mutation from a loader (i.e. a GET request), which is semantically incorrect since GET requests shouldn't have side effects like signing a user out. The FormEvent type used in the save handler was also deprecated.

Solution

  • Converted the "Save changes" button to submit via a <fetcher.Form onSubmit>, matching the pattern already used for approve/reject. The payload is still a nested object rather than flat fields, so it's serialized and sent as JSON through fetcher.submit inside the onSubmit handler (with event.preventDefault()), but it's now wired to a real form element.
  • Replaced the deprecated FormEvent type with SubmitEvent in the save handler.
  • Converted logout from a loader (GET) to an action (POST): the loader now just redirects to / if hit directly via GET, and the actual sign-out mutation lives in the action.
  • Updated the sidebar logout link from a <Link> to a <Form method="post" action="/logout"> with a submit button styled to match the original link.

Reference

N/A

Screenshots

N/A (no visual changes — logout button and save button retain their existing appearance/styling)

Checklist

  • Changes have been tested locally
  • Changes have been self-reviewed

Convert the "Save changes" button on the review detail page from a
bare onClick handler to a <fetcher.Form onSubmit>, matching the
approve/reject actions that already use <Form>. The payload is a
nested object rather than flat fields, so it's still sent as JSON via
fetcher.submit, but routing it through a real form gives us proper
submit semantics (Enter-to-submit, pending state, progressive
enhancement) instead of a plain button click.

Also swap the deprecated FormEvent type for SubmitEvent, and convert
logout to a POST action (was a GET loader) triggered via a <Form> in
the sidebar, since a GET route shouldn't perform a mutation like
signing out.
@tayloraj10
tayloraj10 requested a review from RNR1 August 12, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant