Skip to content

Enhance form documentation for form default reset behavior#8512

Open
MaxwellCohen wants to merge 2 commits into
reactjs:mainfrom
MaxwellCohen:feat/8397/disabling-default-form-reset
Open

Enhance form documentation for form default reset behavior#8512
MaxwellCohen wants to merge 2 commits into
reactjs:mainfrom
MaxwellCohen:feat/8397/disabling-default-form-reset

Conversation

@MaxwellCohen

Copy link
Copy Markdown
Contributor

Summary

Documents React’s default form-reset behavior when using the function action / formAction props, and explains how to preserve field values when you don’t want that reset. Applying @rickhanlonii's feedback from #7795 and building off of work @aurorascharff recentlly did.

  • Adds default reset behavior in Caveats, the action prop section, and a new Troubleshooting entry (“Why does my form reset when I use an action?”). React resets uncontrolled fields after a successful action, matching browser <form action="..."> behavior (including before JS loads).
  • Adds “Preserve form values after submission” with a Sandpack example: call e.preventDefault() in onSubmit, then run the action manually inside useTransition while keeping the action prop for progressive enhancement.
  • Adds a DeepDive for finer control: requestFormReset from react-dom, and returning submitted FormData from server actions to restore values via defaultValue (with useActionState).
  • Updates the multiple-submission-types example to a draft/publish scenario that shows how controlled state and key/defaultValue keep textarea content after “Save draft.”

Closes #8397

Alternative to #7795 and #8465

@github-actions

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

@MaxwellCohen MaxwellCohen marked this pull request as ready for review June 29, 2026 19:09
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.

[Suggestion]: improve <Form> documentation to explain how to keep form state after submission

1 participant