kit icon indicating copy to clipboard operation
kit copied to clipboard

fix: update page store when URL hash is changed from the address bar

Open plbstl opened this issue 2 years ago • 3 comments

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 test and lint the project with pnpm lint and pnpm 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 changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

plbstl avatar Jun 20 '23 23:06 plbstl

🦋 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

changeset-bot[bot] avatar Jun 20 '23 23:06 changeset-bot[bot]

https://github.com/sveltejs/kit/pull/9548 looks to be addressing the same issue

benmccann avatar Jun 21 '23 20:06 benmccann

The draft went stale. I figured out how to resolve the issue and implement the necessary tests

plbstl avatar Jun 21 '23 20:06 plbstl

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.

dummdidumm avatar Jul 04 '23 09:07 dummdidumm

Safari always emit a popstate event on page load

This doesn't happen for me on MacOS Safari 17.

teemingc avatar Jul 04 '23 15:07 teemingc

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.

plbstl avatar Jul 04 '23 16:07 plbstl