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

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

Merged

Conversation

plbstl
Copy link
Contributor

@plbstl plbstl commented Jun 20, 2023

Fixes #9374
Closes #9548


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • 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
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • 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:.

@changeset-bot
Copy link

changeset-bot bot commented Jun 20, 2023

🦋 Changeset detected

Latest commit: cede6c7

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

@benmccann
Copy link
Member

#9548 looks to be addressing the same issue

@plbstl
Copy link
Contributor Author

plbstl commented Jun 21, 2023

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

@dummdidumm
Copy link
Member

dummdidumm commented Jul 4, 2023

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.

@eltigerchino
Copy link
Member

Safari always emit a popstate event on page load

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

@plbstl
Copy link
Contributor Author

plbstl commented Jul 4, 2023

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.

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@dummdidumm dummdidumm merged commit 4d7f38f into sveltejs:master Jul 5, 2023
11 checks passed
@github-actions github-actions bot mentioned this pull request Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$page.url.hash is not updated.
4 participants