Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt): don't try to override computed layouts in definePageMeta #9161

Merged
merged 7 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions examples/routing/layouts/pages/dynamic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@
</div>
</template>

<script>
<script setup>
const layout = ref('custom')
definePageMeta({
layout: false
layout: computed(() => layout.value)
danielroe marked this conversation as resolved.
Show resolved Hide resolved
})
export default {
data: () => ({
layout: 'custom'
})
}
</script>
4 changes: 2 additions & 2 deletions packages/nuxt/src/app/plugins/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ export default defineNuxtPlugin<{ route: Route, router: Router }>((nuxtApp) => {
nuxtApp.hooks.hookOnce('app:created', async () => {
router.beforeEach(async (to, from) => {
to.meta = reactive(to.meta || {})
if (nuxtApp.isHydrating) {
to.meta.layout = initialLayout.value ?? to.meta.layout
if (nuxtApp.isHydrating && initialLayout.value !== undefined && initialLayout.value !== null) {
danielroe marked this conversation as resolved.
Show resolved Hide resolved
to.meta.layout = initialLayout.value
}
nuxtApp._processingMiddleware = true

Expand Down
4 changes: 2 additions & 2 deletions packages/nuxt/src/pages/runtime/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ export default defineNuxtPlugin(async (nuxtApp) => {
const initialLayout = useState('_layout')
router.beforeEach(async (to, from) => {
to.meta = reactive(to.meta)
if (nuxtApp.isHydrating) {
to.meta.layout = initialLayout.value ?? to.meta.layout
if (nuxtApp.isHydrating && initialLayout.value !== undefined && initialLayout.value !== null) {
danielroe marked this conversation as resolved.
Show resolved Hide resolved
to.meta.layout = initialLayout.value
}
nuxtApp._processingMiddleware = true

Expand Down