fix: update page store when URL hash is changed from the address bar
Fixes #9374.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it solves.
- [x] Ideally, include a test that fails without this PR but passes with it.
Tests
- [x] Run the tests with
pnpm testand lint the project withpnpm lintandpnpm check
Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.
🦋 Changeset detected
Latest commit: cede6c710811f1f0cf3a72dc0d1157523e7a3fb1
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| @sveltejs/kit | Patch |
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
https://github.com/sveltejs/kit/pull/9548 looks to be addressing the same issue
The draft went stale. I figured out how to resolve the issue and implement the necessary tests
Reading this section on MDN it says: "Browsers tend to handle the popstate event differently on page load. Chrome (prior to v34) and Safari always emit a popstate event on page load, but Firefox doesn't."
--> Could someone who has access to Safari check whether or not this change results in an unwanted update of the page store on initial page load? Because that shouldn't happen, and if it does, we need some additional boolean I guess to not fire on first page load.
As for the TODO in the code: I think doing it in the else block is correct, you can remove that comment.
Safari always emit a popstate event on page load
This doesn't happen for me on MacOS Safari 17.
Could someone who has access to Safari check whether or not this change results in an unwanted update of the page store on initial page load?
I just checked with Safari on iOS and MacOS, there is no unwanted update of the page store on initial page load.
Safari always emit a popstate event on page load
This doesn't happen to me on Safari 16.5.1 (iOS and MacOS).
As for the TODO in the code: I think doing it in the else block is correct, you can remove that comment.
Okay, thank you for the feedback.