Browse Source

fix: re-render page when navigation error occurred

temporary solution taken from - https://github.com/nuxt/framework/issues/3141

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4431/head
Pranav C 2 years ago
parent
commit
1c31f9fe7c
  1. 27
      packages/nc-gui/app.vue

27
packages/nc-gui/app.vue

@ -6,12 +6,37 @@ const route = useRoute()
const disableBaseLayout = computed(() => route.path.startsWith('/nc/view') || route.path.startsWith('/nc/form'))
useTheme()
// TODO: Remove when https://github.com/vuejs/core/issues/5513 fixed
const key = ref(0)
const messages = [
`Uncaught NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`, // chromium based
`NotFoundError: The object can not be found here.`, // safari
"Cannot read properties of null (reading 'parentNode')",
]
if (typeof window !== 'undefined') {
// @ts-expect-error using arbitrary window key
if (!window.__ncvue) {
window.addEventListener('error', (event) => {
if (messages.includes(event.message)) {
event.preventDefault()
console.warn('Re-rendering layout because of https://github.com/vuejs/core/issues/5513')
key.value++
}
})
}
// @ts-expect-error using arbitrary window key
window.__ncvue = true
}
</script>
<template>
<a-config-provider>
<NuxtLayout :name="disableBaseLayout ? false : 'base'">
<NuxtPage />
<NuxtPage :key="key" />
</NuxtLayout>
</a-config-provider>
</template>

Loading…
Cancel
Save