-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix: correct hash routing behavior #13492
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
Conversation
🦋 Changeset detectedLatest commit: 945805a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@eltigerchino Sorry, I needed to recreate this since the original was on the main branch of my fork, so I couldn't open any other PRs. |
You say it also closes #13460, which makes me nervous. I don't want us to reload everything when the user navigates via a back button. |
It doesn't, that code is only triggered -- as far as I can tell -- for non-navigation |
@dummdidumm To clarify, the issue in #13460 is the deleted code. It does detect user changes to the URL, but it also triggers incorrectly on certain navigations in the browser. So deleting that code fixes #13460 but leaves the app unresponsive to user changes to the hash. To address that (while also resolving #13322), I added the reload for non-navigation |
@elliott-with-the-longest-name-on-github Mildly confused by the tag here -- what decision(s) would need to be made? The current hash router breaks the expected history stack. Deleting the offending code fixes the problem but leaves the app unresponsive to user URL edits. And while you could try to trigger a navigation where I currently have a page reload, you'd run back into #13322 and inconsistency with the pathname router. Is there something I'm overlooking? I'll admit I'm not overly familiar with the codebase. But I'm certainly not triggering page reloads on forward/back-button navigations, at least as far as I can tell. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dug into this some more - the change is sound. Thank you!
closes #13460 and #13322
As is, Kit doesn't correctly handle some aspects of hash routing. Spurious navigations are triggered when using the back button in the browser, but only for certain kinds of routes and in certain environments (see #13460 for details). This seems to be a consequence of differences in when
current.url
is modified, which makes the existing check for user edits to the URL error-prone. Instead (and to also fix #13322), thepopstate
event is used and triggers a simple page reload.Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.Edits