diff --git a/src/shared/nav-guards.js b/src/shared/nav-guards.js index c63d925..135609a 100644 --- a/src/shared/nav-guards.js +++ b/src/shared/nav-guards.js @@ -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) + } + }) }) } diff --git a/test/unit/components.test.js b/test/unit/components.test.js index 2b9e3d0..5d01b20 100644 --- a/test/unit/components.test.js +++ b/test/unit/components.test.js @@ -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() }) @@ -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() })