Repository navigation
fix(pages): keep the page query when an action re-renders the page - #769
Merged
cpojer merged 1 commit intoNov 10, 2026
Merged
Conversation
An action() or useForm submission that posts to the current path now adds
the page's query to the action URL, so the action and loader see it and the
URL, scroll and history entry stay as they are. Keys in the action URL win.
The client names the added segments in X-VoidPages-Preserved-Query, and
named-action c.redirect() leaves them out, so a redirect never inherits the
preserved query. c.redirect('/items') clears it.
Closes voidzero-dev#751
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.
Closes #751
Problem
After an action re-rendered the page, the page shown was the action URL minus its action key. An action posted as
/items?votefrom/items?page=2&search=foore-ran the loader withoutpageorsearch, changed the address bar to/items, reset scroll and pushed a history entry. 7a1a1ce fixed the typed?name&key=valueform; this covers the rest of the issue.Changes
When
action()oruseForm(React, Vue, Svelte, Solid) posts to the current path,submitAction()adds the page's query after the action URL's own parameters:action('/items?vote&page=1')posts withpage=1.Linkandrouter.visit()are unchanged and still send the URL as given.Redirects. Named-action
c.redirect()merges the request query into the location. The client now names the segments it added inX-VoidPages-Preserved-Query, andredirectLocation()strips that suffix before merging. So the preserved query never follows a redirect, andc.redirect('/items')clears it. A query written in the action URL still merges as before. If the request query no longer ends with the named segments (for example after a rewrite with its own query), the header is ignored.Behavior change: an app that relied on an action clearing the query should return
c.redirect('/items'). There is no per-call opt-out.Docs: new "Query parameters after submission" section in
actions-and-forms.md, a note inrewrites.md, and a maintainer note inpackages/void/AGENTS.md.Verification
action-result.test.ts: merge cases (named and default actions, bare?, key precedence, hash, other paths, encoded segments) andaction()with params.routing-runtime.test.ts: the preserved query is left out of default, 303, 307, middleware and rewrite redirects. It stays in the in-place page URL. A header that doesn't match the request query is ignored.pages-client.test.ts: an in-place action from/editor?page=2&search=foosends the merged URL and header, does not scroll or push, and replaces history with the same URL./scroll-restoration?page=2. After each in-place action it checks the URL, the loader'spageandhistory.length, and that the redirect lands on?redirected=1withoutpage=2. It passes in dev and preview for all four adapters. The playground loaders now exposepage.window.location.vp run checkpasses.vp run test: 791 files, 16,600 passed, 37 skipped.🤖 Generated with Claude Code