docs(theme): note layer merging breaks function slot overrides - #6929
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughAdded a Nuxt-only warning to the component theming documentation. The warning states that slot replacement functions must be defined in one layer. Functions defined in multiple Nuxt layers are resolved to strings before Nuxt UI reads them, so they merge with default classes instead of replacing them. Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The documentation now warns Nuxt users that defining function-based slot overrides in multiple layers causes class merging rather than replacement. This clarifies an existing limitation without changing runtime behavior, and no merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The documentation describes the issue and its workaround, but the reported behavior remains unfixed. The latest layer's function does not fully replace the default classes when multiple layers define the same slot, which is the expected behavior in issue
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Merging this PR will improve performance by 12.02%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | plain <button> |
1.3 ms | 1.2 ms | +12.02% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing lazerg:fix/issue-6928 (1107e41) with v4 (970025f)
commit: |
69281d2 to
1107e41
Compare
🔗 Linked issue
Related to #6928
❓ Type of change
📚 Description
Nuxt merges the
app.config.tsof every layer withdefuFn. When a slot is set to a function and the same key already has a value lower down, another layer orappConfiginnuxt.config,defuFncalls that function during the merge and stores what it returns, soapp.config.ui.<component>.slots.<slot>is already a plain string by the time Nuxt UI reads it. A string means merge, which is why the defaults come back instead of being replaced. With a single definition there is nothing under the function, it survives the merge untouched and the replace behaviour works as documented.Nothing is left for Nuxt UI to detect once the merge has run, so this adds a warning next to the function form with the one thing that does work: keep the function in a single place. The issue stays open because the behaviour itself is unchanged. A marker object instead of a bare function (something like
replace('...')) would go through the normal deep merge and survive any number of layers, so that would fix it properly, but it is an API addition. Happy to send that if you want it.📝 Checklist