-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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: ensure search params are not left off of load_cache
#10179
fix: ensure search params are not left off of load_cache
#10179
Conversation
🦋 Changeset detectedLatest commit: 7dbd2f6 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 |
packages/kit/test/apps/basics/src/routes/before-navigate/preserve-search-params/+layout.svelte
Outdated
Show resolved
Hide resolved
packages/kit/test/apps/basics/src/routes/before-navigate/preserve-search-params/+layout.svelte
Show resolved
Hide resolved
…rve-search-params/+layout.svelte Co-authored-by: Willow (GHOST) <[email protected]>
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.
LGTM, hopefully another maintainer can take a look soon to give feedback 🙏
I will go bug @tcc-sejohnson for a review! |
Hmmm, I'm not sure if this is quite right... if I'm understanding correctly, preloading |
@tcc-sejohnson this was actually a bit confusing at first for me too! I'll try my best at a better description: We're not preloading links that have a search param but without ( Please do let me know if you see a better way to tackle this! For a better understanding of the bug, it'll help to start from the repo in the issue linked or the added test. |
Thanks for tackling this! I think the fix is applied at a point that is too late. If the the search param is appended, a In general I'm wondering if we actually want to fix this. what would happen if someone changes the pathname in beforeNavigate(({ from, to, cancel }) => {
const previous_param_value = from?.url.searchParams.get(preserved_param);
if (typeof previous_param_value === 'string') {
const url = new URL(to.url);
url.searchParams.set(preserved_param, 'asd');
cancel();
goto(url);
}
}); Then again, |
@dummdidumm really appreciate you taking a look! Based on what you've shared, I'm also wondering whether this is something we want to explicitly fix -- and whether there's an appropriate "fix" for this based on how/the order of navigation and preloading are currently handled. I can take some more time this week/next to dig a little deeper on the flow of navigation and see if there may be a better approach! |
preview: https://svelte-dev-git-preview-kit-10179-svelte.vercel.app/ this is an automated message |
Closing this since I can't reproduce this original issue after upgrading to the latest version of SvelteKit. |
Closes #10122.
The
load_cache
has no context of any search parameters that exist on the current path. So whendata-sveltekit-preload-data
is enabled for links, search parameters were being left off in thenavigate
function. More specifically, when setting thecurrent
variable which is used to inform thefrom
property inBeforeNavigate
.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:
.