Skip to content

feat(ScrollArea): Add leading/trailing slots#6201

Open
mikenewbon wants to merge 1 commit intonuxt:v4from
mikenewbon:feat/scroll-area-slots
Open

feat(ScrollArea): Add leading/trailing slots#6201
mikenewbon wants to merge 1 commit intonuxt:v4from
mikenewbon:feat/scroll-area-slots

Conversation

@mikenewbon
Copy link
Contributor

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Adds #leading and #trailing named slots to ScrollArea, allowing content to be rendered before and after the scroll items inside the scroll container.

Why: Currently, when using the virtualize, the default slot is consumed per-item — there's no way to inject content like headers, footers, or loading indicators within the scrollable area. These slots fill that gap without breaking changes.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

… rendering

- Introduced `#leading` and `#trailing` slots to the ScrollArea component, allowing for customizable content before and after the scrollable items.
- Updated examples and documentation to demonstrate the new slot functionality.
- Enhanced loading state handling in the infinite scroll example.
@mikenewbon mikenewbon force-pushed the feat/scroll-area-slots branch from bd366bd to 91eb932 Compare March 16, 2026 20:46
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

This change introduces leading and trailing slot support to the ScrollArea component. The core component file (ScrollArea.vue) adds two new optional slot declarations: leading and trailing. These slots enable users to render content before and after scrollable items. Multiple example files have been updated to demonstrate this new functionality, including a new component showing notification items with leading and trailing sections. The documentation has been expanded with new sections explaining the usage of these slots, and the test suite has been extended to cover the new slot scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding leading/trailing slots to ScrollArea component.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose and motivation for adding leading/trailing slots to ScrollArea.
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 unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@github-actions github-actions bot added the v4 #4488 label Mar 16, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/components/ScrollArea.spec.ts (1)

29-29: Keep explicit per-item default-slot coverage in the matrix.

Line 29 currently validates default-slot rendering without items. Consider adding a separate case with props so per-item slot props (item, index) remain directly covered.

♻️ Suggested test matrix tweak
-    ['with default slot', { slots: { default: () => 'Default slot' } }],
+    ['with default slot and items', { props, slots: { default: ({ item }) => item.name } }],
+    ['with default slot (no items)', { slots: { default: () => 'Default slot' } }],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/components/ScrollArea.spec.ts` at line 29, Add an explicit matrix case
that covers per-item default-slot props by duplicating the existing "with
default slot" entry but adding props: { items: [...] } and replacing the slot
factory to accept and assert item/index (e.g., slots: { default: (item, index)
=> /* use item/index in output or assertions */ }). Locate the current matrix
entry "with default slot" (slots: { default: () => 'Default slot' }) in
ScrollArea.spec.ts and add a new case like "with default slot and items" that
passes a small items array so the test verifies per-item slot props are
exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/components/ScrollArea.spec.ts`:
- Line 29: Add an explicit matrix case that covers per-item default-slot props
by duplicating the existing "with default slot" entry but adding props: { items:
[...] } and replacing the slot factory to accept and assert item/index (e.g.,
slots: { default: (item, index) => /* use item/index in output or assertions */
}). Locate the current matrix entry "with default slot" (slots: { default: () =>
'Default slot' }) in ScrollArea.spec.ts and add a new case like "with default
slot and items" that passes a small items array so the test verifies per-item
slot props are exercised.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2e151a0f-1a74-4c2c-9244-4a732bdb09fc

📥 Commits

Reviewing files that changed from the base of the PR and between 886f5fb and 91eb932.

⛔ Files ignored due to path filters (2)
  • test/components/__snapshots__/ScrollArea-vue.spec.ts.snap is excluded by !**/*.snap
  • test/components/__snapshots__/ScrollArea.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (6)
  • docs/app/components/content/examples/scroll-area/ScrollAreaInfiniteScrollExample.vue
  • docs/app/components/content/examples/scroll-area/ScrollAreaLeadingTrailingExample.vue
  • docs/content/docs/2.components/scroll-area.md
  • playgrounds/nuxt/app/pages/components/scroll-area.vue
  • src/runtime/components/ScrollArea.vue
  • test/components/ScrollArea.spec.ts

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 16, 2026

npm i https://pkg.pr.new/@nuxt/ui@6201

commit: 91eb932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant