Skip to content
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

switchLocalePath does not keep query params in URL #2354

Closed
martinsjek opened this issue Aug 30, 2023 · 5 comments · Fixed by intlify/routing#46 or #2397
Closed

switchLocalePath does not keep query params in URL #2354

martinsjek opened this issue Aug 30, 2023 · 5 comments · Fixed by intlify/routing#46 or #2397
Labels
good first issue 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage PR Welcome routing v8

Comments

@martinsjek
Copy link

Environment

  • Operating System: Linux
  • Node Version: v18.17.1
  • Nuxt Version: 3.7.0
  • CLI Version: 3.7.2
  • Nitro Version: 2.6.2
  • Package Manager: npm@9.6.7
  • Builder: -
  • User Config: modules, css, vite, nitro, runtimeConfig, router, app, image, i18n, security, robots, gtag, htmlValidator, telemetry, $test
  • Runtime Modules: @nuxtjs/i18n@8.0.0-rc.3, @nuxt/image@1.0.0-rc.1, @pinia/nuxt@0.4.11, @vueuse/nuxt@10.4.1, @nuxtjs/tailwindcss@6.8.0, nuxt-security@0.14.4, nuxt-vitest@0.10.2, @artmizu/nuxt-prometheus@2.1.5, nuxt-gtag@0.6.2, @nuxtjs/robots@3.0.0, @nuxtjs/html-validator@1.5.2
  • Build Modules: -

Reproduction

.

Describe the bug

When using const switchLocalePath = useSwitchLocalePath();
As switchLocalePath('en')

URL changes, but it does not keep query parameters, example:
URL is /cart?test=123
After switchLocalePath it is /en/cart
But I need /en/cart?test=12

I am using strategy: 'prefix_except_default',

Additional context

No response

Logs

No response

@q1103192605
Copy link

I have the same problem and can't find a solution

@kazupon kazupon added v8 good first issue routing PR Welcome 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage and removed pending triage labels Sep 2, 2023 — with Volta.net
@RobertsG
Copy link

RobertsG commented Sep 7, 2023

Was using this for my product page with filters, where I need them to stay persistent.
So I'm also interested in this.

@BobbieGoede
Copy link
Collaborator

Could you provide a minimal reproduction of this issue? I am unable to replicate it, here is a starter project you can use.

@tomsdob
Copy link

tomsdob commented Sep 8, 2023

@BobbieGoede the issue can be replicated with the starter project you provided. Open the app in a new tab and add any query parameter to the URL, for example ?test=123, open the page with the query params. After that click on any of the links that use switchLocalePath, the query parameter is gone.

Example:
Edit ...webcontainer.io/en to ....webcontainer.io/en?test=123
When you are in ...webcontainer.io/en?test=123, click on Nederlands NuxtLink.
Now the URL is ...webcontainer.io/nl and the query params are gone. Should be ...webcontainer.io/nl?test=123.

@BobbieGoede
Copy link
Collaborator

@tomsdob you're right! I'm not sure what I was looking at that I couldn't replicate it. I think I have found the source of the issue and opened a PR to potentially resolve it. It's quite a weird issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage PR Welcome routing v8
Projects
None yet
6 participants