Skip to content

next() callback in beforeRouteEnter stopped working with Vue 2.5.16 #2188

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

Closed
mrnateriver opened this issue May 8, 2018 · 2 comments
Closed

Comments

@mrnateriver
Copy link

Version

3.0.1

Reproduction link

http://jsfiddle.net/09Lom5h4/3/

Steps to reproduce

Reproduced with Vue 2.5.16.

  1. Open provided jsfiddle.net link;
  2. Open browser console;
  3. Click on 'first a' ;
  4. Click on 'first b' ;
  5. Click on 'second a' ;
  6. Click on 'second b';
  7. And click on 'first a' again;
  8. Inspect console output.

What is expected?

Callback passed to next() call in beforeRouteEnter hook must be called at all times.

Expected console output:

beforeRouteEnter:
vue-component-3: mounted
vm.title: first_a
beforeRouteEnter:
vm.title: first_b
beforeRouteEnter:
vue-component-4: mounted
vm.title: second_a
beforeRouteEnter:
vm.title: second_b
beforeRouteEnter:
vue-component-3: mounted
vm.title: first_a

What is actually happening?

Something very peculiar.

The callback (let's call it CB) that's passed to next() only gets called for an instance of component that is mounted first. Any transitions to other instances of that component do trigger beforeRouteEnter hook, but CB doesn't get called. However, if you transition to other instances, and then back to the first one, CB gets called again.

Actual console output:

beforeRouteEnter:
vue-component-3: mounted
vm.title: first_a
beforeRouteEnter:
<-- missing output: vm.title: first_b
beforeRouteEnter:
vue-component-4: mounted
vm.title: second_a
beforeRouteEnter:
<-- missing output: vm.title: second_b
beforeRouteEnter:
vm.title: first_b <-- this is another bug, which is already reported, issue 2062
vue-component-3: mounted

This behaviour appeared somewhere between Vue versions 2.5.13 and 2.5.16, (almost) everything is fine with 2.5.13:

http://jsfiddle.net/09Lom5h4/4/

I said almost fine, because it overlaps with another bug:

#2062

I've actually used the JSFiddle from that issue to demonstrate this one.

@nirazul
Copy link

nirazul commented Jun 19, 2018

Any update on this one? The projects on which I need to fix the vue version to 2.5.15 are piling up slowly and introduce other problems.

Is there anything we can do to help fixing this?

@posva
Copy link
Member

posva commented Jul 12, 2018

Thanks for reporting this, let's keep #2255 which points out another problem as well

@posva posva closed this as completed Jul 12, 2018
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