-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Passing an undefined query param can prevent the url from updating #2641
Comments
For the moment the way to do it is to remove the property from the object (instead of providing undefined). The thing is it is kept in Technically, removing the query parameters would be a breaking change so I will keep this open for next major version |
@posva To be clear, using undefined to remove a query parameter already works:
Using undefined only fails in some circumstances. |
I'm talking about this, these are how the tests should be written: undefined values should be removed from resulting query object it('should work consistently', () => {
router.push({ query: { bar: 'bar' } })
router.push({ query: { bar: undefined } })
expect(location.hash).toEqual('#/')
expect(router.app.$route.query).toEqual({ })
})
it('should support the example use case', () => {
router.push({ query: { q: 'foo', color: 'bar' } })
router.push({ query: { q: 'foo', color: undefined } })
expect(location.hash).toEqual('#/?q=foo')
expect(router.app.$route.query).toEqual({ q: 'foo' })
}) Technically it would be a breaking change |
Closing as this was fixed in v4 |
Version
3.0.2
Reproduction link
https://plnkr.co/edit/yJJpcKuhYQwdOk3nZcZs?p=preview
Steps to reproduce
/?q=foo&color=bar
.this.$router.push({query: {q: 'foo', offset: undefined}})
What is expected?
I expect the url to change to
/?q=foo
What is actually happening?
The url does not change
I'm doing search filtering using query params. Every time I change a filter, I
add/remove/modify the appropriate param, and reset my pagination by setting
an offset param to undefined. In my app, the combination of removing a param
and offset not being set to begin with, causes the route not to update.
This issue is easy enough to work around, but it took me a while to figure out
what was going on.
The text was updated successfully, but these errors were encountered: