-
-
Notifications
You must be signed in to change notification settings - Fork 5k
beforeRouteEnter not calling next callback and beforeRouteUpdate not called when using the same component on two routes #2255
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
Comments
@coxy When downgrading to Vue 2.4.4 in your sandbox, and keeping vue-router at v3.0.1, it seems to work as expected |
Thanks @bryanpackman - I tried a few other versions and can confirm it works as expected all the way up to vue 2.5.15 (see https://codesandbox.io/s/1yyz9m1ll) so looks like the issue only applies to vue 2.5.16 + vue-router 3.0.1. If I get some time I'll try to debug what's causing the issue |
Same for me. On the application I’m working on, I was also able to get |
Also confirming. Just in case some "newbies" are around, the way you downgrade is by issuing:
I tried tracking down the relevant commits in upstream (from here), but I'm a bit out of my depth as to what could be the cause of the issue. |
FYI: |
Just for the sake of completeness: This bug has already been reported a while ago: #2082 |
@coxy You're right, that's probably a related but separate bug |
As a workaround, you can set a |
Setting I tried to update vue and vue-loader up to mentioned beta v2.5.17-beta.0, but I still have troubles with that callback being called. Sorry for not providing the fiddle (maybe later), but I will describe scenario:
|
Can confirm that 2.5.17-beta.0 fixes the problem. For me 2.5.2 and 2.5.16 were affected, other versions notwithstanding. |
Seems to be not fixed on 2.5.17. |
I'm having the same problem. beforeRouteUpdate stops working when using the same comp in 2 routes. https://codepen.io/hecktarzuli/pen/PBybaW?editors=1011
Vue-Router: 3.0.1 |
@posva I can't find any documentation on :key for router-view. Where can I find out more on what it does so I can figure out the best solution? (key isn't listed in the api docs.. https://router.vuejs.org/api/#router-view-props) |
it's vue's api |
Right, but for for-loops so.. (shrug). I tried using it with $route.fullPath and bad things happened in my app so it looks like I'm reverting to 2.5.15 :P |
Yeah, this approach of using a key in the |
Current version has an issue not invoking router hooks. See vuejs/vue-router#2255
Need to decrement Vue version because of the bug vuejs/vue-router#2255
Just looking at the diff between v2.5.15..v2.5.16, the fix for vuejs/vue#7805 looks like it might contain the regression here, which itself is a regression fix at vuejs/vue@984927a (this is the only code in that diff that seems to refer to hooks, and there’s a pretty substantial change in hook assignment there). As v2.5.17-beta.0 seems to have worked and v2.5.17 doesn’t, here’s the diff that exists for that change: https://github.com/vuejs/vue/compare/v2.5.17-beta.0..v2.5.17 It looks like v2.5.17-beta.0 reverted the fix for vuejs/vue#7805 and the final brought it back in ( This behaviour is deeply problematic for the project I’m working on, but I will temporarily work around it by locking to 2.5.15 and hope that one of the bugs fixed since 2.5.15 doesn’t affect us. |
Workaround In my case, the problem is that I have a component which calls its own route when it needs to set a new parameter to the URL. And then it has to fetch the data with the new parameter value once the route is set. before: With this approach, I was able to have the |
Is this fixed in 2.5.21? I can't tell which of the 5.2 million similar bugs mine specifically falls under, but I verified that downgrading to 2.5.15 fixed my issue, then it remained fixed after upgrading to 2.5.21. |
Remains fixed for me in 2.5.21 as well! |
Yes, can confirm this issue is fixed with 2.5.21. I'm going to close this now but feel free to re-open if the problem comes back |
Actually, in my case this issue persists. I have a set of views that use the |
@jorngeorg maybe it's best to log a new issue for that as it's a little more specific (I'm also not 100% sure what the expected behaviour here should be when used in combination with |
Same old issue, "vue": "^2.6.11", |
next(vm=> is not firing at all :(
Seems to be a pretty important issue :o |
vue 3.2.11, vue-router 4.0.12 ( + ionic/vue 5.8.0, ionic/vue-router 5.8.0 ) |
The same here with vue 3.2.23 and vue-router 4.0.12. Callback passed to next is never called. |
Same problem with vue 3.2.1 and vue-router 4.0.0. |
Version
3.0.1
Reproduction link
https://codesandbox.io/s/qqoy3zox0j
Steps to reproduce
Click on each of the links in order in the example and also check the console.
What is expected?
I would expect the beforeRouteUpdate to be called after each page transition as all the routes share the same component.
What is actually happening?
Firstly, the route transition from Page 2 to Nested Page 1 calls the beforeRouteEnter hook, but doesn't execute the next callback (hence why count doesn't update). Secondly, the route transition from Nested Page 1 to Nested Page 2 doesn't call either the beforeRouteEnter or the beforeRouteUpdate hooks.
The text was updated successfully, but these errors were encountered: