feat(ScrollArea): add getScrollElement virtualize option#233
Merged
Conversation
Port of upstream nuxt/ui a84de85 (#6650).
Adds a `getScrollElement` option to `ScrollAreaVirtualizeOptions`, letting the
component virtualize against an external ancestor scroll container instead of
its own root viewport:
- new `getScrollElement?: () => Element | null` option
- `isExternalScroll` + a `getScrollElement()` resolver, used by the virtualizer
- `getVirtualItemStyle` subtracts `scrollMargin` from the item start in external
mode so items sit inline
- the resize-observer moves from `onMounted` to
`watch(getScrollElement, …, { immediate: true })` so it re-observes when the
scroll element changes
- root gets `overflow: visible` in external mode (it no longer owns the scroll)
Adds a renderEach spec case (2 snapshots regenerated) and a docs section. The
docs example is adapted to b24ui conventions and trimmed to the feature core
(external scroll container + scrollMargin); upstream's incidental find-toolbar
is omitted. Adds 3 icon-map entries.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JS8ypVfQSFzYVZzkTHhURb
This was referenced Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream
a84de85—feat(ScrollArea): add getScrollElement virtualize option (#6650)Change
Lets
ScrollAreavirtualize against an external ancestor scroll container instead of its own root viewport:getScrollElement?: () => Element | nullinScrollAreaVirtualizeOptions(removed from theOmitexclusion)isExternalScrollcomputed + agetScrollElement()resolver (external el when provided, elserootRef.$el), used by the virtualizergetVirtualItemStylesubtractsscrollMarginfromvirtualItem.startin external mode (offset) so items sit inlineonMountedtowatch(getScrollElement, …, { immediate: true })so it re-observes when the scroll element changes (onMountedimport dropped)overflow: visiblein external mode (it no longer owns the scroll)Component — 1:1
b24ui's
ScrollArea.vuematched upstream's pre-change structure; all script + the:stylechange applied verbatim (only the pre-existingb24ui.rootclass binding differs, untouched).Tests
Added the
with virtualize external scroll elementrenderEachcase verbatim (getScrollElement: () => document.body, scrollMargin: 20). 2 snapshots regenerated — the new case rendersstyle="overflow: visible;"on the root, the feature demonstrating itself. Full suite 5145 passed (+2 vs 5143) / 6 skipped.Docs — adapted & trimmed (deviation)
Ported the
### With external scroll elementmd section (badge New, per b24ui convention, not upstream'sSoon) with the same explanation +note/caution. The example is trimmed to the feature core: an external scrollcontainerowning the scroll, a sticky header measured viauseElementSize(border-box) feedingscrollMargin, andB24ScrollAreawith{ getScrollElement, scrollMargin, estimateSize, skipMeasurement }overB24PageCard/B24Userrows (samedummyjsonfetch b24ui'sScrollAreaInfiniteScrollExamplealready uses) + a "Top" button (B24Button,ArrowToTheTopIcon,color="air-tertiary").Dropped upstream's incidental "find" toolbar (search input + prev/next-match buttons + result counter +
UBadge/UFieldGroup) — demo sugar, not part of the feature, and itsneutral/subtle/outline+ iconify mappings carry design-judgment risk in a non-test-validated example. Can follow as a separate doc enhancement if wanted.useElementSizeis imported explicitly from@vueuse/core(not auto-imported in b24ui docs).Maps (§4)
Added 3
icon-map.jsonentries:i-lucide-arrow-up-to-line→actions/ArrowToTheTopIcon,i-lucide-chevron-up→outline/ChevronTopSIcon(b24icons names up-chevrons "Top"),i-lucide-search→main/Search2Icon.Verify (CI=true)
dev:prepare·lint·typecheck(docs example compiles) ·test·build— all green.Ledger
.sync/log/a84de85….md— port rationale.sync/nuxt-ui.json— adda84de85asport, advance cursor (= upstream v4 HEAD); reconcile priordf099a5→ PR chore(deps): update actions/checkout action to v7 #232 /49d01ae6.🤖 Generated with Claude Code
Generated by Claude Code