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

Unset route query on default value is not working anymore #3290

Closed
7 tasks done
greenhalos opened this issue Aug 3, 2023 · 5 comments · Fixed by #3583
Closed
7 tasks done

Unset route query on default value is not working anymore #3290

greenhalos opened this issue Aug 3, 2023 · 5 comments · Fixed by #3583

Comments

@greenhalos
Copy link

greenhalos commented Aug 3, 2023

Describe the bug

Setup

Package: @vueuse/router

<script setup>
import { useRouteQuery } from "@vueuse/router";
const search = useRouteQuery("search", "defaultValue");
</script>

Expected Beahviour and Behaviour of Version v10.2.1

When I change the value of search to the default value (in this case "defaultValue"), the query parameter is removed from the URL:

search.value = "defaultValue";

Behaviour in Version v10.3.0

When changing the value of search to the default value (in this case "defaultValue"), the parameter remains in the URL.

Further Notes

In my production use case the default value is "" which leads to to a paramter ?search=

Further observations

Reproduction

https://github.com/greenhalos/useRouteQuery-bug-default

System Info

Binaries:
    Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
    npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
    pnpm: 8.6.11 - ~/.local/share/pnpm/pnpm
  npmPackages:
    @vueuse/core: 10.3.0 => 10.3.0 
    @vueuse/router: 10.3.0 => 10.3.0 
    vue: ^3.2.25 => 3.3.4

Used Package Manager

npm

Validations

@vuthanhbayit
Copy link

vuthanhbayit commented Oct 2, 2023

I just want to ask, when I use:

const state = reactive({
  name: useRouteQuery('name', ''),
})

watch(state, (newValue, oldValue) => {
  console.log(newValue === oldValue) // true
  console.log(newValue.name === oldValue.name) // true
})

when changing the value of state.name, console.log in watch returns true.
How does it work? Tks for watching

Copy link

stale bot commented Dec 1, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 1, 2023
@greenhalos
Copy link
Author

I have rebased the pull request to the latest commits of the main branch, so it is ready again to be reviewed

@stale stale bot removed the stale label Dec 2, 2023
Copy link

stale bot commented Feb 1, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 1, 2024
@stale stale bot closed this as completed Feb 8, 2024
@greenhalos
Copy link
Author

It is fixed via #3583

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