Skip to content
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

Provide index for custom item component #220

Closed
aeharding opened this issue Oct 24, 2023 · 2 comments · Fixed by #249
Closed

Provide index for custom item component #220

aeharding opened this issue Oct 24, 2023 · 2 comments · Fixed by #249
Assignees

Comments

@aeharding
Copy link
Sponsor Contributor

Is your feature request related to a problem? Please describe.

[data-index] is an attribute Virtuoso provides on each virtual list div, where the value is the index of the item in the array. It would be nice to be able to have data-index on each div, either out of the box or with some customization.

It is helpful to track where you are on the list to perform actions, for example, scrolling to the next virtual list item.

Describe the solution you'd like

Something like one of these:

  • CustomItemComponentProps has index (type=number) for user to build custom item with data-index
  • [data-index] on each virtual list div, out of the box

Describe alternatives you've considered

I can add index inside each item in my implementation. That works, but is tedious and adds another layer of div in my usage.

@inokawa
Copy link
Owner

inokawa commented Oct 25, 2023

Hi,
I personally prefer the adding index prop to CustomItemComponentProps approach. And I agree there are no good way to know item index in item wrapper components (some hacks are possible though).

@inokawa
Copy link
Owner

inokawa commented Nov 21, 2023

Released in 0.16.5.

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 a pull request may close this issue.

2 participants