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

beforeRouteUpdate fire twice when query contain empty array [] #1754

Closed
newbeea opened this issue Sep 20, 2017 · 3 comments
Closed

beforeRouteUpdate fire twice when query contain empty array [] #1754

newbeea opened this issue Sep 20, 2017 · 3 comments

Comments

@newbeea
Copy link

newbeea commented Sep 20, 2017

Version

2.7.0

Reproduction link

http://jsfiddle.net/a9v43732/

Steps to reproduce

go to foo
then click 'beforeRouteUpdate' button
beforeRouteUpdate fire twice when query contain empty array []

eg.
this.$router.push({query: {a: Math.random(), b: []}})
beforeRouteUpdate fire twice

this.$router.push({query: {a: Math.random(), b: [1]}})
beforeRouteUpdate fire once

What is expected?

this.$router.push({query: {a: Math.random(), b: []}})
beforeRouteUpdate shoud fire once

What is actually happening?

this.$router.push({query: {a: Math.random(), b: []}})
beforeRouteUpdate fire twice

@posva
Copy link
Member

posva commented Sep 20, 2017

This is probably related to #1722
The route object gets normalized and the array is stripped off, making the route change fire twice.
As a temporary workaround, you can remove empty arrays from query objects

@posva posva closed this as completed Sep 20, 2017
@ghost
Copy link

ghost commented Jan 17, 2019

@posva This also happens without sending any route parameters. Should i open new issue with example?

@posva
Copy link
Member

posva commented Jan 17, 2019

if there isn't an open issue about it and you provide a boiled down repro, yes please!

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

2 participants