Skip to content

fix bug beforeEnter fire twice on root path ('/') after async call #735

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

Merged
merged 1 commit into from
Oct 13, 2016

Conversation

billouboq
Copy link
Contributor

@billouboq billouboq commented Oct 7, 2016

Issue #725

I might be wrong but I think this.transitionTo(getHash()) fire the 'hashchange' event, so if next is not called synchronously in beforeEnter function, the second call to transitionTo will trigger beforeEnter again.

Dunno if it's better but we can use setTimeout to deferrer the hashchanged listener, works too.

ensureSlash()
this.transitionTo(getHash())

setTimeout(() => {
    window.addEventListener('hashchange', () => {
        this.onHashChange()
    })
}, 0)

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

Successfully merging this pull request may close these issues.

2 participants