Skip to content

fix: respect replaceState/keepFocus/noScroll when a navigation results in a redirect - #14424

Merged
Rich-Harris merged 38 commits into
sveltejs:mainfrom
PatrickG:issue-13403
Sep 14, 2025
Merged

Rich-Harris merged 38 commits into
sveltejs:mainfrom
PatrickG:issue-13403

Conversation

@PatrickG

Copy link
Copy Markdown
Member

Fixes #13403

An alternative to #13303 that does not change invalidate()/invalidateAll()


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot

changeset-bot Bot commented Sep 13, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5ffc846

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

@PatrickG PatrickG changed the title Issue 13403 fix: respect replaceState/keepFocus/noScroll when a navigation results in a redirect Sep 13, 2025

@Rich-Harris Rich-Harris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful! thank you

@Rich-Harris
Rich-Harris merged commit fc7bce6 into sveltejs:main Sep 14, 2025
35 of 36 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 14, 2025
@FilippoSalvarani21

FilippoSalvarani21 commented Sep 15, 2025 •

Copy link
Copy Markdown

This happens even with redirect(), shouldn't it be included?
example:
If I navigate from pageA to pageB -> redirected to pageC in server.js. I expect to go back from C to A, instead It goes to pageB.

@PatrickG

PatrickG commented Sep 15, 2025 •

Copy link
Copy Markdown
Member Author

@FilippoSalvarani21 can you create a new issue? Preferably with a minimal reproduction.
Are you sure you've tested with this PR?
Keep in mind that this PR is not released yet.
It will be released as version 2.40.0 when #14422 gets merged.

Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
…results in a redirect (sveltejs#14424)

* respect replace_state on external navigation where applicable

* changeset

* added tests

* fixed client navigation

* prettier

* changeset

* take out trash

* take out trash

* take out trash

* Apply suggestion from @eltigerchino

* changeset

* fix typo

* Apply suggestion from @eltigerchino

* Update .changeset/dirty-rats-divide.md

* Delete packages/kit/test/apps/basics/src/routes/navigation/nonexistent/.gitkeep

* add replaceState to invalidate

* fix test

* move tests to `goto` suite

* change tests according to code review suggestions

* take out trash

* test fix

* fix lint

* fix typo

* typedef

* typedef

* fix lint

* refactor test

* Revert "fix lint"

This reverts commit 481e1ab.

* remove opts from invalidate/All

* always set `replaceState` to `true` when a load function throws a redirect while invalidating

* call navigate directly and forward other state as well

* sort imports like on main

* we don't need an `opts` object on `native_navigation`

* revert invalidate in tests

* revert invalidate/All types

* changelog

* 20

---------

Co-authored-by: akonstantinov <akonstantinov@ozon.ru>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
teemingc added a commit that referenced this pull request Oct 14, 2026
…17440)

- Service-worker lookup/update failures escape both deployment-recovery
paths and prevent full-document navigation.
- Retain the awaited refresh introduced in
[#12448](#12448) and documented in
[#16310](#16310); deleting or
fire-and-forgetting it loses the opportunity to install an updated
worker before reloading.
- Catch failures in the shared helper rather than individual callers;
preserve module-failure recovery
([#8487](#8487)), version gating
([#16496](#16496)), and
replacement-history semantics
([#14424](#14424)).
- Cover synchronous/rejected lookups, failed updates, missing
registrations, and successful-update sequencing in both route-load and
error-status recovery.

Fixes #17435

<!--
svelte-triage-bot:feedback-baseline:50cc6409e1816477e9f7fd0bb3702a95dc6b5e4f
-->

---------

Co-authored-by: svelte-triage-bot <team@svelte.com>
Co-authored-by: Tee Ming <chewteeming01@gmail.com>
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.

goto with replaceState: true not respected in redirects

5 participants