Skip to content

fix: fall back to full navigation when partial redirect has no partials#3716

Merged
bartlomieju merged 2 commits into
mainfrom
fix/partial-redirect-fallback
Mar 29, 2026
Merged

fix: fall back to full navigation when partial redirect has no partials#3716
bartlomieju merged 2 commits into
mainfrom
fix/partial-redirect-fallback

Conversation

@bartlomieju

Copy link
Copy Markdown
Contributor

Summary

When a form POST (or link click) within f-client-nav results 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

  1. Form with f-partial="/routes/submit" submits a POST
  2. Server handler returns a 301/302 redirect to /another-place
  3. Client follows the redirect, gets a full HTML page with no <Partial> markers
  4. applyPartials() throws NoPartialsErrorunhandled in click/submit handlers
  5. Nothing happens visually; the user is stuck

The fix

fetchPartials() now catches NoPartialsError internally. When the response was a redirect (res.redirected) and no partials were found, it falls back to location.href = actualUrl.href for a full-page navigation. Non-redirect NoPartialsError cases still propagate (the popstate handler already catches those for back-button navigation).

Test plan

  • Lint/format clean
  • Manual test: form with f-partial that redirects to a non-partial page should navigate correctly

🤖 Generated with Claude Code

bartlomieju and others added 2 commits March 28, 2026 09:15
…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>
@bartlomieju bartlomieju enabled auto-merge (squash) March 29, 2026 19:38
@bartlomieju bartlomieju merged commit 14cff12 into main Mar 29, 2026
9 checks passed
@bartlomieju bartlomieju deleted the fix/partial-redirect-fallback branch March 29, 2026 19:42
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.

Inside f-partial-nav the server-side redirects do not work.

1 participant