Skip to content

fix: only preload link if the URL differs from current page #12773

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

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

eltigerchino
Copy link
Member

@eltigerchino eltigerchino commented Oct 9, 2024

fixes #10234

By avoiding preloading pages where the URL pathname and search params (the load ID) are unchanged, we also avoid mistakenly caching navigation results for hash URLs. Currently, these are ID'd the same as URLs without hashes, causing navigation to lose track of the current URL (hence the original issue).

This should be a good solution because:

  1. if we're on already on the page we don't need new load results for it.
  2. even if the load results are suppose to be different for the same URL, clicking on a link that leads to the exact same URL already does nothing.

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

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

Sorry, something went wrong.

@eltigerchino eltigerchino added the bug Something isn't working label Oct 9, 2024
Copy link

changeset-bot bot commented Oct 9, 2024

🦋 Changeset detected

Latest commit: d8d011f

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

@eltigerchino eltigerchino changed the title fix: only preload if the URL is different from the current page fix: only preload links if the URL differs from current page Oct 9, 2024
@eltigerchino eltigerchino changed the title fix: only preload links if the URL differs from current page fix: only preload link if the URL differs from current page Oct 9, 2024
@dummdidumm dummdidumm merged commit 571f731 into main Oct 9, 2024
13 checks passed
@dummdidumm dummdidumm deleted the fix-anchor-link-preload branch October 9, 2024 10:15
@github-actions github-actions bot mentioned this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Same route anchor links only fire once when a hash link is preloaded with data-sveltekit-preload-data
2 participants