Skip to content

Commit

Permalink
fix: call afterNavigation after nextTick (#478)
Browse files Browse the repository at this point in the history
* fix: afterNavigation

* style: use arrow function
  • Loading branch information
ricardogobbosouza authored and pimlie committed Oct 28, 2019
1 parent c6b20eb commit fa12530
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/shared/nav-guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ export function addNavGuards (rootVm) {
})

router.afterEach(() => {
const { metaInfo } = resume(rootVm)
rootVm.$nextTick(() => {
const { metaInfo } = resume(rootVm)

if (metaInfo && isFunction(metaInfo.afterNavigation)) {
metaInfo.afterNavigation(metaInfo)
}
if (metaInfo && isFunction(metaInfo.afterNavigation)) {
metaInfo.afterNavigation(metaInfo)
}
})
})
}
4 changes: 4 additions & 0 deletions test/unit/components.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ describe('components', () => {
expect(wrapper.vm.$root._vueMeta.pausing).toBe(true)

guards.after()
expect(afterNavigation).not.toHaveBeenCalled()
await vmTick(wrapper.vm)
expect(afterNavigation).toHaveBeenCalled()
})

Expand Down Expand Up @@ -306,6 +308,8 @@ describe('components', () => {
expect(wrapper.vm.$root._vueMeta.pausing).toBe(true)

guards.after()
expect(afterNavigation).not.toHaveBeenCalled()
await vmTick(wrapper.vm)
expect(afterNavigation).toHaveBeenCalled()
})

Expand Down

0 comments on commit fa12530

Please sign in to comment.