From 914d4b64a3af5f42a16034f1dc22b5b129d9728f Mon Sep 17 00:00:00 2001 From: mkucmus Date: Mon, 29 Jun 2020 23:28:22 +0200 Subject: [PATCH] fix: load the main navigation elements - watch issue --- packages/default-theme/components/SwTopNavigation.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/default-theme/components/SwTopNavigation.vue b/packages/default-theme/components/SwTopNavigation.vue index d79a6c2f1..4832d8923 100644 --- a/packages/default-theme/components/SwTopNavigation.vue +++ b/packages/default-theme/components/SwTopNavigation.vue @@ -54,14 +54,19 @@ export default { switchOverlay(!!currentCategoryName.value) } - onMounted(() => { - watch(currentLocale, async () => { + onMounted(async () => { + await watch(currentLocale, async () => { try { await fetchNavigationElements(3) } catch (e) { console.error("[SwTopNavigation]", e) } }) + + // fixes a watch issue - fetch the elements if watch wasn't fired + if (Array.isArray(navigationElements) && !navigationElements.length) { + fetchNavigationElements(3) + } }) return {