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

useRouteParams doesn't allow removing the parameter by setting it to empty string / null / undefined #3536

Open
7 tasks done
mtdvlpr opened this issue Nov 9, 2023 · 2 comments

Comments

@mtdvlpr
Copy link
Contributor

mtdvlpr commented Nov 9, 2023

Describe the bug

I'm using @vueuse/router and @vueuse/nuxt. I have a page that has one required route param and one optional route param. When trying to remove the optional param using the ref from useRouteParams, the url doesn't change correctly. I've tried setting the ref to an empty string, null and undefined. Tried with and without a default value for the route param. Doesn't work.

Reproduction

https://github.com/mtdvlpr/reproduction

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 20.55 GB / 31.70 GB
  Binaries:
    Node: 18.18.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.6.4 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (119.0.2151.44)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @vueuse/nuxt: ^10.5.0 => 10.5.0
    @vueuse/router: ^10.5.0 => 10.5.0
    nuxt: ^3.8.1 => 3.8.1
    vue: ^3.3.8 => 3.3.8

Used Package Manager

yarn

Validations

@lukvxx
Copy link

lukvxx commented Nov 17, 2023

I can confirm this and would be very happy if you guys could fix it.. A empty query parameter is painfull. Either it exists or it doesnt.

@thejoecode
Copy link

This appears to be a bug in the router when changing params but not route: vuejs/router#1893

The current work around is to use empty string to remove the optional parameters. There is also a fix in the works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants