Repository navigation
fix(react): derive form state from submission outcomes and guard concurrent submits - #738
Merged
cpojer merged 2 commits intoNov 7, 2026
Conversation
…urrent submits - Represent useForm submission results with a discriminated union (SubmissionOutcome) owned by useActionState, deriving errors, error, hasChanges, wasSuccessful, and recentlySuccessful without redundant state or refs. - Snapshot form data and dispatchData at dispatch time so synchronous setData() calls, in-flight edits (including under resetOnSuccess), and queued React actions preserve their submitted payload and post-success baseline. - Scope callbackOutcomeRef across async onError and synchronous onSuccess so reset(), setError(), clearErrors(), and clearError() inside callbacks operate on the incoming outcome without leaking uncommitted defaults to external UI interactions during await. - Return a fresh idle outcome when a submission aborts so previous validation errors or success states do not revive. - Represent useIslandForm state with a single IslandOutcome union and requestId so the latest started submission owns pending and UI state across completion orders. - Check 429 retryAt deadlines directly in <Form> onSubmit instead of mounting timer state and effects.
Keep the submission outcome available until onSuccess settles so reset and field errors still target the successful submission after await. Reset uses the accepted snapshot while the callback is pending and retains the previous baseline until the request succeeds.
6 tasks done
yangshun
added a commit
to yangshun/void
that referenced
this pull request
Nov 9, 2026
…olid A second submit aborts the first through the router, and the first's cleanup then cleared `pending` while the second was still running. An older submit that still completed could also apply its errors, success state and defaults. Island forms have no abort, so an older response could overwrite a newer result, reload the page or redirect. Only the latest submit now updates form state or changes the page, matching the request ID guard React's useIslandForm gained in voidzero-dev#738. An older submit's real failure still rejects its own promise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yangshun
added a commit
to yangshun/void
that referenced
this pull request
Nov 9, 2026
…d Solid On success these forms saved their values as of the response, so anything typed while the request was in flight counted as saved: `hasChanges` read false and `reset()` restored text that was never submitted. `resetOnSuccess` also wiped those edits, and page forms sent a shallow copy that shared nested values with the live form. Each form now takes a deep copy when submit starts, sends it and saves it as the new defaults. `resetOnSuccess` only clears the data if it has not changed since submit. This matches what React's forms have done since voidzero-dev#738. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cpojer
pushed a commit
that referenced
this pull request
Nov 9, 2026
) ## Summary Brings `useForm` and `useIslandForm` in Vue, Svelte and Solid in line with React, fixing two bugs in how they handle a submit that is still in flight. ## Why the adapters differ All four adapters used to share these bugs. [#738](#738) fixed them in React only, so React has guarded concurrent submits and kept submitted values since then, while Vue, Svelte and Solid have not. ## The issues **1. An older submit could still change the form when a newer one was running** (`3c9ddc5ae`) The forms tracked submits with flags and did not record which one was latest. - **Page forms:** a second submit aborts the first through the router, and the first's `finally` then set `pending = false` while the second was still running. A submit button disabled by `pending` became clickable again mid-request. An older submit that still completed could also apply its errors, success state and defaults. - **Island forms:** nothing aborts the older request, so its response could overwrite a newer result, clear `pending`, reload the page or redirect, whichever finished first. **2. Edits made during a submit counted as saved** (`e4ca5a713`) On success, the forms saved their values as of the response rather than as of the submit. - `hasChanges` read `false`, and `reset()` restored text that was never sent. - `resetOnSuccess` wiped anything typed while the request was in flight. - Page forms sent a shallow copy, so nested values were shared with the live form. ## The fix - Each form counts its submits with `requestId` and `latestRequestId`, the same names React's island form uses. Only the latest submit updates state, reloads or redirects. An older submit's real failure still rejects its own promise. - Each form takes a deep copy when submit starts, sends it and saves it as the new defaults. - `resetOnSuccess` only clears the data if it has not changed since submit. - The `hasChanges` and `resetOnSuccess` docs now cover edits made during a submit. Most of that diff is the formatter repadding the table. ## Behaviour that still differs from React - **Two page-form submits:** React's `useActionState` queues them, while Vue, Svelte and Solid abort the first and keep the latest. This PR keeps that difference. The server may still have processed an aborted request. - **`resetOnSuccess` edit check:** these adapters compare values, because their form data is mutated in place, while React compares object identity. Typing something and changing it back counts as unchanged here. ## Test plan New tests cover both finishing orders, aborts, older failures, in-flight edits and `resetOnSuccess`, based on the React test added in #738. Solid's are in a new file because they need its client runtime. They assert through `reset()` rather than `hasChanges`, because `createStore` and `createMemo` do not track each other under those test mocks. - [x] All new tests that assert the bugs failed before their fix (18 for overlap, 9 for in-flight edits) - [x] Form tests for all four adapters pass (72) - [x] Vue, Svelte and Solid typechecks, format and lint pass - [x] `vp run check` passes (33/33) - [x] CI passes on `e4ca5a713` - [x] Local browser tests on the rebased code. `vp test run` had 16,106 tests pass and 41 fail, every failure being `browserType.launch: Executable doesn't exist`, because this machine lacks the Chromium build Playwright 1.65 expects 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useForm()status (errors,error,hasChanges,wasSuccessful,recentlySuccessful) from theuseActionStateoutcome instead of syncing separate states and refs acrossawait.resetOnSuccess: true) keep their submitted payload and baseline.reset(),setError(),clearErrors(), andclearError()insideonSuccess/onErrorapply to the new outcome without exposing uncommitted defaults duringawait.useIslandForm()with a request ID so the latest submission ownspendingand UI state across out-of-order completions.retryAtdeadlines directly in<Form>onSubmitinstead of mounting a timer effect.Test plan
vp fmt --check&vp lintvp run build&vp run check:sdkvp test run packages/react/test/unit