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

Abstract mode starts with a negative history index #3020

Closed
wrosa-pariveda opened this issue Nov 6, 2019 · 1 comment

Comments

@wrosa-pariveda
Copy link

@wrosa-pariveda wrosa-pariveda commented Nov 6, 2019

Version

3.1.3

Reproduction link

https://jsfiddle.net/s0kag18p/2/

Steps to reproduce

Create a new Vue Router in Abstract Mode

const router = new Router({ mode: 'abstract', routes: [{path: '/', component: {render: function(h){return h('div', 'Hello World!')}}}]})

What is expected?

Expect router.history.index to be 0

What is actually happening?

router.history.index is -1


The main issue this is causing me is that the first router.push() call will increase the index to 0 when it should be increased to 1. What this means is that router.back() does nothing until the second navigation, when router.history.index is set to 1, when it should be 2.

This basically makes it impossible to navigate back until my stack has 3 or more navigated routes.

F.Y.I. For some reason JSFiddle doesn't work with Vue Router in abstract mode, but the code is correct. (Comment out the mode and you'll see)

@posva

This comment has been minimized.

Copy link
Member

@posva posva commented Nov 7, 2019

This is normal since abstract mode starts in a nowhere state and doing that initial push is necessary to start the router. Differently from other histories, abstract do not have access to the url to start the history automatically

@posva posva closed this Nov 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.