Add svelte sticky groups#899
Open
kbaratyants wants to merge 1 commit into
Open
Conversation
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.
Summary
We needed sticky date-separator headers in a chat-style virtualized list (Svelte), similar to what's already possible in React/Vue/Solid via the "Sticky Group" pattern. The Svelte package didn't support this because
Virtualizer/VListonly accepteditemas an HTML tag name — there was no way to attach extrastyle/class/attributes to a specific item's wrapper element, which is required to flip an item fromposition: absolutetoposition: stickyat scroll time.Rather than hack around this at the story/consumer level, we added first-class
itemPropssupport to the Svelte package (src/svelte), mirroring the existing VueitemPropsAPI:Virtualizer/VListnow accept anitemProps?: (payload: { item, index }) => { style?, class?, ...attrs }prop.styleis merged on top of the item wrapper's base positioning styles (so overrides likeposition/toptake effect), and any other returned attributes (e.g.class) are spread onto the wrapper element.WindowVirtualizeris untouched — Vue doesn't exposeitemPropsthere either, so there's no parity gap to close.With that in place, we ported the existing "Sticky Group" Storybook story (already present for React/Vue/Solid) to Svelte, demonstrating sticky group headers built entirely on public API — no internal hacks needed.
No dedicated unit test was added for
itemProps, matching the existing convention in this repo (the VueitemPropsimplementation has no dedicated unit test either) — coverage here is the existingVList/VirtualizerSSR spec suite plus manual verification via the new Storybook story.Test plan
npm run test -- --project=sveltepasses (existing suite, unchanged)npm run check:sveltereports no new errorsnpm run storybook:svelte→ "advanced/Sticky Group" story: scroll through the list and confirm the active group header (0, 100, 200, …) sticks to the top and hands off correctly at each boundary