Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let hash changes be handled by the router #830

Conversation

lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Apr 2, 2021

Allow router to handle hash only changes in order to make browser (back) navigation to hash routes work.
Fixes #821

@benmccann
Copy link
Member

Hmm. I'm not quite sure I understand the issue. If I go to https://kit.svelte.dev/docs, click a section in the lefthand side menu, click the github link at the top of the page, then click back, it still goes to the section I clicked on and has # in the URL

It's also interesting that it was explicitly disallowed before. I'd kind of want to know the reason for that. It might be helpful to find the change in Sapper that introduced that line

@lukasIO
Copy link
Contributor Author

lukasIO commented Apr 13, 2021

The issue only manifests itself if the second link (after clicking on the hash link) is also a route within the SvelteKit project. You can check the reproduction repository in #821 to confirm or alternatively run the tests that I added in 31e0e87 on the current implementation to confirm.

@benmccann
Copy link
Member

I still need to review this, but in the meantime can you add a changeset by running pnpx changeset?

@lukasIO
Copy link
Contributor Author

lukasIO commented Apr 23, 2021

maybe the right way to go about this, would be to choose to history.replaceState for hash only navigation? Not entirely sure what the desired behaviour should be.

@benmccann
Copy link
Member

Thanks for your patience on this PR. I finally got a chance to test it and I think it looks good as is. Can you rebase it? Then I think we can merge

@benmccann benmccann force-pushed the fix-browser-back-navigation-not-working-for-hash-routes branch from bd58ce7 to 0e4054b Compare May 19, 2021 22:55
@benmccann benmccann merged commit ec156c6 into sveltejs:master May 19, 2021
@lukasIO
Copy link
Contributor Author

lukasIO commented May 20, 2021

thanks @benmccann for reviewing and rebasing!

andyburke pushed a commit to andyburke-forks/kit that referenced this pull request May 25, 2021
Co-authored-by: lukasio <mail@lukasseiler.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

navigating (back) to a route with hash does not work
2 participants