kit icon indicating copy to clipboard operation
kit copied to clipboard

$page store does not react to certain navigation changes or stores incorrect data

Open gyzerok opened this issue 1 year ago • 1 comments

Describe the bug

I've found two bugs with navigating using both goto and pushState related to $page store.

When navigating with goto to the same route as the current one even though $page.state changes no $effect runs on it.

When using pushState and passing new url to it you get stuck with $page.params pointing to the previous incorrect url.

Reproduction

Here is the repo: https://github.com/gyzerok/sveltekit-nav-bug

Bug with goto and state:

  1. Go to page /bug
  2. Click goto button
  3. No effects run and console log anything (expected console log about state change)
  4. Click Log $page button and see that actually state in the $page changed

With Svelte I strongly expect that if some state changes the effects are run as a result of this change which is not the case here.

Bug with pushState and url:

  1. Go to page /bug
  2. Click on pushState button
  3. You get a log where params.id: "bug", however in the browser url you see /test

Logs

No response

System Info

@sveltejs/kit: 2.6.1
svelte: 5.0.0-next.260

Severity

serious, but I can work around it

Additional Information

No response

gyzerok avatar Oct 02 '24 03:10 gyzerok

also related to https://github.com/sveltejs/kit/issues/11503 where the page store is not being notified of updates made to it

teemingc avatar Oct 18 '24 07:10 teemingc

@eltigerchino it looks like the first part of this bug is fixed with https://github.com/sveltejs/kit/pull/13196, however the second one is still in place.

I've updated my repo with the latest version of svelte and sveltekit.

gyzerok avatar Dec 22 '24 05:12 gyzerok

closing as duplicate of https://github.com/sveltejs/kit/issues/13200 . I've tested and this is fixed by https://github.com/sveltejs/kit/pull/13205 . You can also test this with the PR's changes by running

npm add https://pkg.pr.new/sveltejs/kit/@sveltejs/kit@13205

teemingc avatar Dec 23 '24 03:12 teemingc