fix: fall back to full navigation when partial redirect has no partials#3716
Merged
Conversation
…ls (#2560) When a form submission or link click within f-client-nav triggers a server-side redirect to a page that doesn't contain any <Partial> components, the client now falls back to a full page navigation instead of silently failing. Previously, fetchPartials would throw an unhandled NoPartialsError in the click and form submit handlers, causing nothing to happen visually. Now the error is caught inside fetchPartials itself and when the response was a redirect, it navigates to the redirect target via location.href. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move maybeUpdateHistory() after applyPartials() so that when a redirect falls back to full navigation, we don't leave a duplicate history entry that requires pressing back twice. Co-Authored-By: Claude Opus 4.6 (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.
Summary
f-partial-navthe server-side redirects do not work. #2560 — "Insidef-partial-navthe server-side redirects do not work"When a form POST (or link click) within
f-client-navresults in a server-side redirect to a page that doesn't have any<Partial>components, the client now falls back to a full-page navigation (location.href) instead of silently doing nothing.The problem
f-partial="/routes/submit"submits a POST/another-place<Partial>markersapplyPartials()throwsNoPartialsError— unhandled in click/submit handlersThe fix
fetchPartials()now catchesNoPartialsErrorinternally. When the response was a redirect (res.redirected) and no partials were found, it falls back tolocation.href = actualUrl.hreffor a full-page navigation. Non-redirectNoPartialsErrorcases still propagate (the popstate handler already catches those for back-button navigation).Test plan
f-partialthat redirects to a non-partial page should navigate correctly🤖 Generated with Claude Code