-
-
Notifications
You must be signed in to change notification settings - Fork 435
URL query change doesn't trigger preload method #701
Comments
I've come around to considering this an outright bug. In #484 (0.25.0), the behavior was changed so that these query-only navigations caused preload to be re-run, and this behavior changed in 0.26.0 for Svelte 3. |
Hoo boy, this is a tricky one. I can see myself sometimes wanting a refresh on query change and maybe other times not wanting that behavior. I'm wondering if there ought to be an idiomatic way of expressing what the author wants...hmm... Update: what does React/Vue/Angular do? Could we look to their example(s)? |
As I noted in chat:
I think possibly the way to address this is with some sort of additional logic here that also marks |
@Conduitry So, this works fine in 0.25.0? Can I use it with Svelte 3? I mean, maybe I just need to downgrade sapper until bug won't be fixed. |
No, 0.25.0 is only for Svelte 2. This behavior changed again in 0.26.0 as part of the rewrite for Svelte 3. |
@Conduitry Oh, sad. (( |
The change in #484 doesn't actually do any checking for changed query string, it just makes it so that the deepest layer always is marked as changed. A somewhat analogous change here is: diff --git a/runtime/src/app/app.ts b/runtime/src/app/app.ts
index 3f5e8e1..cfd9402 100644
--- a/runtime/src/app/app.ts
+++ b/runtime/src/app/app.ts
@@ -296,7 +296,7 @@ export async function hydrate_target(target: Target): Promise<{
branch = await Promise.all(route.parts.map(async (part, i) => {
const segment = segments[i];
- if (current_branch[i] && current_branch[i].segment !== segment) segment_dirty = true;
+ if (current_branch[i] && (current_branch[i].segment !== segment || i === route.parts.length - 1)) segment_dirty = true;
props.segments[l] = segments[i + 1]; // TODO make this less confusing
if (!part) return { segment }; but I'm not comfortable just suggesting that yet. I'm back to not knowing what the right behavior is here. |
More musings from chat: What if |
always re-run preload functions when query string changes
@Rich-Harris Thank you very much! |
I am having this issue right now. I use preload to load paginated data - and I still got the exact same problem as the posed question describes. |
Hi! If we have a link like this:
and click it, this won't trigger
preload
to fetch the data again:I believe it shoud work, but it didn't.
The text was updated successfully, but these errors were encountered: