8000 fix(nuxt): update NuxtPage when nested NuxtLayout has name=false by Flo0806 · Pull Request #34078 · nuxt/nuxt · GitHub
[go: up one dir, main page]

Skip to content

fix(nuxt): update NuxtPage when nested NuxtLayout has name=false#34078

Merged
danielroe merged 1 commit intonuxt:mainfrom
Flo0806:fix/nuxt-layout-name-false
Jan 20, 2026
Merged

fix(nuxt): update NuxtPage when nested NuxtLayout has name=false#34078
danielroe merged 1 commit intonuxt:mainfrom
Flo0806:fix/nuxt-layout-name-false

Conversation

@Flo0806
Copy link
Member
@Flo0806 Flo0806 commented Jan 14, 2026

🔗 Linked issue

Fixes #34074

📚 Description

  • Fixes NuxtPage not re-rendering when navigating between routes with a nested <NuxtLayout :name="false">
  • When name=false, isCurrent() now returns true so NuxtPage renders normally instead of returning cached vnode

Tests

  • Added unit test for nested NuxtLayout with name=false

@Flo0806 Flo0806 requested a review from danielroe as a code owner January 14, 2026 18:53
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pkg-pr-new
Copy link
pkg-pr-new bot commented Jan 14, 2026

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@34078

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@34078

nuxt

npm i https://pkg.pr.new/nuxt@34078

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@34078

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@34078

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@34078

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@34078

commit: 4789512

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Jan 14, 2026

Walkthrough

This pull request addresses a bug where NuxtPage fails to render route changes when nested inside a NuxtLayout with the name prop set to false. The fix updates the LayoutProvider's isCurrent logic to treat a false name as always being the current layout, allowing proper re-rendering on route transitions. Documentation is updated to clarify that the name prop accepts false as a valid value, and test cases are added to verify the corrected behaviour.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: fixing NuxtPage re-rendering when a nested NuxtLayout has name=false.
Description check ✅ Passed The description clearly explains the bug fix, the implementation change, and confirms that tests were added.
Linked Issues check ✅ Passed The PR successfully addresses the requirements in issue #34074 by modifying isCurrent() to return true when name is false, enabling proper NuxtPage re-rendering.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the nested NuxtLayout name=false issue: documentation updates, component fix, and test additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🧹 Recent nitpick comments
test/nuxt/nuxt-layout.test.ts (1)

192-216: Good coverage for the reported regression; add unmount to avoid test pollution.
Because this suite already keeps el mounted from beforeAll, consider unmounting nestedEl at the end of this test (and optionally prefer get('h3') for clearer failures).

Proposed tweak
   it('should update NuxtPage when nested NuxtLayout has name=false', async () => {
@@
     // Page content (h3) should update even with name=false on inner layout
     expect.soft(nestedEl.find('h3').text()).toBe('Current route: /layout-2')
+
+    nestedEl.unmount()
   })

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf19660 and 4789512.

📒 Files selected for processing (3)
  • docs/4.api/1.components/3.nuxt-layout.md
  • packages/nuxt/src/app/components/nuxt-layout.ts
  • test/nuxt/nuxt-layout.test.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Follow standard TypeScript conventions and best practices

Files:

  • test/nuxt/nuxt-layout.test.ts
  • packages/nuxt/src/app/components/nuxt-layout.ts
**/*.{ts,tsx,js,jsx,vue}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx,js,jsx,vue}: Use clear, descriptive variable and function names
Add comments only to explain complex logic or non-obvious implementations
Keep functions focused and manageable (generally under 50 lines), and extract complex logic into separate domain-specific files
Remove code that is not used or needed
Use error handling patterns consistently

Files:

  • test/nuxt/nuxt-layout.test.ts
  • packages/nuxt/src/app/components/nuxt-layout.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for core functionality using vitest

Files:

  • test/nuxt/nuxt-layout.test.ts
🧠 Learnings (2)
📚 Learning: 2025-09-10T14:42:56.647Z
Learnt from: Tofandel
Repo: nuxt/nuxt PR: 33192
File: test/nuxt/use-async-data.test.ts:366-373
Timestamp: 2025-09-10T14:42:56.647Z
Learning: In the Nuxt useAsyncData test "should watch params deeply in a non synchronous way", the foo watcher intentionally updates both params.foo and params.locale using locale.value, simulating a scenario where one watcher consolidates multiple reactive values into a shared params object for testing debounced/non-synchronous behavior.

Applied to files:

  • test/nuxt/nuxt-layout.test.ts
📚 Learning: 2024-12-12T12:36:34.871Z
Learnt from: huang-julien
Repo: nuxt/nuxt PR: 29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.

Applied to files:

  • packages/nuxt/src/app/components/nuxt-layout.ts
🪛 LanguageTool
docs/4.api/1.components/3.nuxt-layout.md

[uncategorized] ~25-~25: Loose punctuation mark.
Context: ...ucture/app/layouts"} ## Props - name: Specify a layout name to be rendered, c...

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: test-fixtures (windows-latest, built, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, async, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, built, webpack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, js, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, default, manifest-off, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite-env-api, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, webpack, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, rspack, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (windows-latest, dev, vite-env-api, async, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, built, vite, default, manifest-on, json, lts/-1)
  • GitHub Check: test-fixtures (ubuntu-latest, dev, vite, async, manifest-off, json, lts/-1)
  • GitHub Check: test-size
  • GitHub Check: typecheck (windows-latest, bundler)
  • GitHub Check: typecheck (ubuntu-latest, bundler)
  • GitHub Check: release-pkg-pr-new
  • GitHub Check: test-benchmark
  • GitHub Check: code
🔇 Additional comments (2)
docs/4.api/1.components/3.nuxt-layout.md (1)

25-27: Docs update looks correct and aligns with :name="false" semantics.
Minor thought: consider explicitly stating that false renders the default slot without a layout wrapper (i.e. “no layout”), to make the behaviour unambiguous.

packages/nuxt/src/app/components/nuxt-layout.ts (1)

146-148: Fix looks right: name === false treated as always current to avoid NuxtPage caching.
Nice short-circuiting too (avoids calling routeRulesMatcher when name is false). If LayoutProvider can ever receive name === true at runtime (boolean is accepted), it may be worth guarding it as “no layout” defensively, but that’s outside this PR’s core change.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codspeed-hq
Copy link
codspeed-hq bot commented Jan 14, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing Flo0806:fix/nuxt-layout-name-false (4789512) with main (cf19660)

Summary

✅ 10 untouched benchmarks

@danielroe danielroe merged commit 37763a5 into nuxt:main Jan 20, 2026
56 of 58 checks passed
@github-actions github-actions bot mentioned this pull request Jan 20, 2026
danielroe pushed a commit that referenced this pull request Jan 21, 2026
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NuxtPage fails to render route changes when nested inside a NuxtLayout with :name="false"

2 participants

0