fix(partials): keep GET form values in the page URL - #3902
Open
limkaa4 wants to merge 1 commit into
Open
Conversation
Submitting a GET form inside `f-client-nav` updated the partial but left the address bar at the bare `action`, so the submitted values disappeared from the URL. A native form navigation puts them there, and apps that keep UI state in the URL lose that state on reload, when copying the link, and on back/forward. When no `f-partial` is given, both URLs start from the same `action`, but the form fields were appended only to the URL used for fetching. Append them to the navigated URL as well. With `f-partial` the split between the page URL and the data URL is preserved. Co-Authored-By: Claude Opus 5 (1M context) <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.
What happens now
Submitting a
GETform insidef-client-navupdates the partial, but theaddress bar keeps the bare
action— the submitted values are gone from it./?name=foo/The partial itself receives the values — only the page URL does not reflect them.
Why it matters
The state a user just produced is no longer in the URL, so it is lost on
reload, cannot be copied or bookmarked, and does not survive back/forward.
For apps that keep UI state in the URL — filters, search, sorting — the same
form behaves differently depending on whether JS is running, which defeats
progressive enhancement.
Cause
Both URLs start from the same
actionwhen nof-partialis given:The form fields are then appended to
partialUrlonly, whileactionUrliswhat
fetchPartialswrites into history. So the two drift apart even thoughnothing asked them to.
Change
Append the fields to the navigated URL as well. With
f-partialthe splitbetween "page URL" and "data URL" is preserved — only the page URL now carries
the submitted values, as a native navigation would.
Tests
Added
partials - form submit puts values into the page url: submits a GETform, asserts the URL equals
/?name=foo, and checks island state survives, sothe assertion cannot be satisfied by a full page reload. It fails on
mainandpasses with this change. All existing partials tests pass unchanged.
🤖 Generated with Claude Code