Skip to content

fix(react): let useForm reset to mount-time defaults after submit - #568

Open
0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:cursor/fix-useform-reset-initial-0ad5
Open

0froq wants to merge 1 commit into
voidzero-dev:mainfrom
0froq:cursor/fix-useform-reset-initial-0ad5

Conversation

@0froq

@0froq 0froq commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #523

Summary

After a successful submit, useForm still promotes submitted values to defaults (edit forms / hasChanges unchanged). You can now get back to mount-time values:

  • reset({ initial: true }, ...fields) — reset to the values passed to useForm on mount
  • resetOnSuccess: true on useForm options — clear create forms after success
  • reset() without options still targets current defaults (last submitted values after success)

Shared via parseFormResetArgs in void/pages-client; React / Vue / Svelte / Solid + docs / codegen.

Tests

  • packages/void/test/unit/form-reset.test.ts
  • packages/vue/test/unit/use-form.test.ts (reset / reset({ initial: true }) / resetOnSuccess)

Typecheck: void, @void/react, @void/vue, @void/svelte, @void/solid.

🐸

Fixes voidzero-dev#523

## Summary

After a successful submit, `useForm` still promotes submitted values to defaults (edit forms / `hasChanges` unchanged). You can now get back to mount-time values:

- `reset({ initial: true }, ...fields)` — reset to the values passed to `useForm` on mount
- `resetOnSuccess: true` on `useForm` options — clear create forms after success
- `reset()` without options still targets current defaults (last submitted values after success)

Shared via `parseFormResetArgs` in `void/pages-client`; React / Vue / Svelte / Solid + docs / codegen.

## Tests

- `packages/void/test/unit/form-reset.test.ts`
- `packages/vue/test/unit/use-form.test.ts` (reset / `reset({ initial: true })` / `resetOnSuccess`)

Typecheck: `void`, `@void/react`, `@void/vue`, `@void/svelte`, `@void/solid`.

Co-authored-by: froQ <sayhola@froq.me>

This branch has not been deployed

No deployments
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.

React useForm: reset() restores the last submitted values, not the initial ones

2 participants