paoloricciuti / sveltekit-search-params

The easiest way to read and WRITE from query parameters in sveltekit.
https://sveltekit-search-params.netlify.app
MIT License
478 stars 13 forks source link

defaultValue not applyed in a second client side navigation #41

Closed jycouet closed 8 months ago

jycouet commented 11 months ago

Describe the bug

I have this setting:

const store_qp = queryParameters({
  withOne: ssp.boolean(true),
  withTwo: ssp.boolean(false),

  pushHistory: false,
})

First time I see the page, I see my queryParams getting updated, it's all good. Then, I navigate (client side), and when at some point I go back to this page, defaults don't get applied.

When, I leave the page, my +page.svelte get destoyed well. So I'm not sure what's happening.

Thanks for your help

Reproduction

https://www.sveltelab.dev/?provider=github&owner=jycouet&repo=veltekit-search-params-default-value

  1. Navigate to Page A ✅ query param are displayed and applied
  2. Navigate to Page B ✅ Nothing special, it's going there
  3. Navigate to Page A ❌ Default query params are not applied.

Logs

No response

jycouet commented 8 months ago

Any insights @paoloricciuti ?

paoloricciuti commented 8 months ago

Any insights @paoloricciuti ?

Yeah I plan to look into this in the near future

paoloricciuti commented 8 months ago

The PR should fix it however i noticed something interesting: if you never use the store it never trigger the redirect (i guess it's because it never subscribe to the store)