sveltejs / sveltejs/kit

`afterNavigate` gets called on previous page if it has a global transition

Open
#12,547 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

svelte
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the bug

Normally from navigating from page A to page B the callback flow is the following:

  1. A - beforeNavigate
  2. A - onNavigate
  3. B - afterNavigate

But, when page A has a component with transition|global, it's afterNavigate is also called. I think this is a bug, or should at least be documented.

Related: #12545

Reproduction

https://www.sveltelab.dev/kgvookzyzs3eb87

Severity

annoyance

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked SvelteLab reproduction and compare navigation from a page with a global transition against the documented callback order. Trace the navigation and transition lifecycle to determine why the previous page receives afterNavigate, then verify that only the destination page does and that the existing callback sequence remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.