Skip to content

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

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:cursor/fix-useform-reset-initial-0ad5
Oct 26, 2026
Merged

cpojer merged 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>

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense, thank you!

@cpojer
cpojer merged commit 308f442 into voidzero-dev:main Oct 26, 2026
2 checks passed
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

3 participants