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

[BUG] No way to have original index with <GroupedVirtuoso /> #938

Open
georgeLacs opened this issue Jun 26, 2023 · 1 comment
Open

[BUG] No way to have original index with <GroupedVirtuoso /> #938

georgeLacs opened this issue Jun 26, 2023 · 1 comment
Labels
PR welcome You can give that a try :) sponsor-or-pr Contribute or sponsor the solution using GH sponsors

Comments

@georgeLacs
Copy link

georgeLacs commented Jun 26, 2023

There is no way to have original index when using

Reproduction
https://codesandbox.io/s/staging-flower-q9xljn?file=/App.js

To Reproduce
Steps to reproduce the behavior:

  1. Go to Sandbox
  2. On generated list, indexes are displayed just like a flatMap. However it is important to return original index.
  3. Original index, on example, is expected to be like

- Group 2
  Virtual Index: 20 / Original Index: 0 / (Group 2)
  Virtual Index: 21 / Original Index: 1 / (Group 2)
  Virtual Index: 22 / Original Index: 2 / (Group 2)
  Virtual Index: 23 / Original Index: 3 / (Group 2)
  Virtual Index: 24 / Original Index: 4 / (Group 2)
  Virtual Index: 25 / Original Index: 5 / (Group 2)
  Virtual Index: 26 / Original Index: 6 / (Group 2)
  Virtual Index: 27 / Original Index: 7 / (Group 2)
  Virtual Index: 28 / Original Index: 8 / (Group 2)
  Virtual Index: 29 / Original Index: 9 / (Group 2)

Expected behavior

  • Update itemContent props to return (index: number, primaryIndex: number, groupIndex: number, data: D, context: C) or something like that

Desktop (please complete the following information):

  • react-virtuoso 4.3.11 (latest)
@georgeLacs georgeLacs added the bug Something isn't working label Jun 26, 2023
@petyosi petyosi added PR welcome You can give that a try :) sponsor-or-pr Contribute or sponsor the solution using GH sponsors and removed bug Something isn't working labels Jun 26, 2023
@gnapse
Copy link

gnapse commented Apr 30, 2024

I spent a few minutes after my first use of virtuoso trying to figure out why it was calling itemContent with indices that were out of range for my grouped data structure. Until I realized that it was a flat index, what's being passed. That's unintuitive. In a grouped data structure, I would assume that item indices are 0-based per group. I agree with what's reported in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR welcome You can give that a try :) sponsor-or-pr Contribute or sponsor the solution using GH sponsors
Projects
None yet
Development

No branches or pull requests

3 participants