Skip to content

feat: Add CollectionNode to collection renderer #8523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nwidynski
Copy link
Contributor

This adds an optional CollectionNode component to the collection renderer interface, which enables customization of a nodes render output without having to re-implement the entire renderer. This can be useful to build wrapper components which modify a nodes pseudo content without breaking an existing custom renderer, e.g. <Virtualizer />.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@nwidynski
Copy link
Contributor Author

@devongovett Would love to hear your thoughts on this. For more context, this PR relates to #8317 (comment). Let me know if the docs need updates as well here!

@devongovett
Copy link
Member

So you are looking for some kind of "inheritance" for collection renderers basically? Like use virtualizer but add an extra wrapper element around items? Can you describe in a bit more detail how your use case (a carousel I guess?) works?

One concern is that it could be somewhat easy to mess up the DOM structure expected by an existing renderer, but maybe it's an advanced use case anyway so you know the risks.

I was going to say the default collection renderer was pretty simple so it wouldn't be too hard to copy, but the drop indicator stuff is kinda complicated now so maybe this makes sense.

Do you usually want to wrap just the item itself or also wrap the drop indicators?

Sorry for all the questions just trying to think through the use cases here.

@nwidynski
Copy link
Contributor Author

nwidynski commented Jul 12, 2025

@devongovett Yes, thats right! The primary idea for this PR was to be able to create a component similar to Autocomplete, which composes around a collection component and is able to modify the content after/before the drop indicator. More specifically, we were simulating an infinite loop of collection items by rendering clones of the opposite collection side (e.g. item n-1 before item 1) at the first and last collection item respectively, then moving scroll position when hitting the boundaries. This meant we had to place clones outside of the drop indicators, which otherwise would be pushed out of view.

PS: We have already moved on from this implementation to one based on a Virtualizer, but nevertheless this PR would make sense i feel like. More on our implementation soon, as I will try to contribute the full Carousel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants