sveltejs/sapper

Scroll position is not reset after a redirect

Closed this issue · 6 comments

When using this.redirect in a preload block, the scroll position is not reset after clicking a link that should redirect.

Here's a reproduction

Scroll down and click on the link at the bottom, and notice that your scroll position does not get reset.

The redirect is being made here: https://github.com/Jayphen/sapper-noscroll-redirect-bug/blob/master/src/routes/%5B...path%5D.svelte

I simply have a catch-all route that redirects if the path is /blah.

Just to add to the above: presumably redirects should always result in scroll restoration, since the primary use case is patching up old links after a site migration. I can't think of any reason you would not want to scroll to 0,0, but if there is some reason perhaps this could be an option to this.redirect

Yeah, I agree it should take you to the top of the page. If this is something you want to send a PR for, I would review it and help you get it in

Sure, can you please assign me here so I don't forget?

done

This should be fixed in 0.28.4

Indeed it is!