paoloricciuti/sveltekit-search-params

defaultValue not applyed in a second client side navigation

Closed this issue · 3 comments

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

Any insights @paoloricciuti ?

Any insights @paoloricciuti ?

Yeah I plan to look into this in the near future

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)