Navigation to an anchor link from another page doesn't work, and only takes you to the top of the page. However, navigation to an anchor link does work if you are already on the page.
I encountered this issue when trying to create drop-down top navigation items that take you to an anchor within another page.

You can reproduce the error here: https://github.com/alizauf/another-anchor-test
This may be related to https://github.com/sveltejs/sapper/issues/331 (and thanks @mhkeller) for a convenient sample repo to easily demonstrate.
@Rich-Harris, correct if I'm wrong on this issue.
I believe that Sapper uses roadtrip (or part of it) for routing. Roadtrip is made with some inspiration from page.js and both of them suffer from this issue.
I am with the same problem but I have not had enough time to address this issue yet, and I'm starting to dig on this issue right now.
If I find a solution, I will happily do a PR to both page.js and sapper, as I've done before (on page.js and sapper).
@Rich-Harris if I submit a PR to roadtrip, is it easy for you to re-adapt it to sapper?
@paulocoghi I think I might have just yanked the code from roadtrip/page that filtered out anchor tags that the router shouldn't be concerned with — they're not in sync or anything. But if there's a fix that works for one then hopefully it'll work for all...
@Rich-Harris, here are my current findings:
My temporary solution is to call scrollIntoView¹ inside the router, because:
scrollIntoView to the element with the id used on the hash linkscrollIntoView¹ 93+% browser support when not using the smooth option
I need more time to infer if it is possible to improve our routers' logic in a way where we don't need to call anything and succeed in all possible navigation cases.
Until then, I believe that using scrollIntoView is probably the best solution.
Fixed by @DayBr3ak in 0.23.1!
Hurray! Thanks @DayBr3ak !
Most helpful comment
Fixed by @DayBr3ak in 0.23.1!