question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Wrong startIndex and endIndex rangeChanged callback in GroupedVirtuoso component

See original GitHub issue

Describe the bug Using GroupedVirtuoso with rangeChanged callback, the range startIndex and endIndex returned by the function sometimes emit wrong values.

i have this summarized implementation:

<GroupedVirtuoso
          data={users}
          style={{ height: 200 }}
          groupCounts={[500, 500]}
          rangeChanged={(range) => console.log(range)}
          ref={virtuoso}
          itemContent={(index, _, user) => {
            return (
              <div {...item} />
            );
          }}
        />

Reproduction https://codesandbox.io/s/sandpack-project-forked-i1hkpv?file=/App.js

To Reproduce Steps to reproduce the behavior:

  1. Click on ‘Scroll to 500’
  2. See the log of the rangeChanged callback
  3. If everything is normal, then scroll the list up and down

Expected behavior I think the expected behavior is the rangeChanged emit only indexes that the list is rendering on the screen. And the startIndex cannot be greater than endIndex. For example, in the image below:

  • First log: The startIndex: 497 and endIndex: 1 should never happens because it endIndex cannot be smaller than startIndex
  • Last log: The startIndex: 1 and endIndex: 502 should not be printed because all of this items list is not being rendered at this time.

Screenshots image

Desktop (please complete the following information):

  • OS: Ubuntu Linux
  • Browser: Chrome

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
petyosicommented, Jul 13, 2022

Confirming that, it’s a weird bug. I will look into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using overscan leads to incorrect rangeChanged indices #118
I'd expect them to still only include the visible content (as I'd like to use this callback to determine what's actually visible).
Read more >
Range Change Callback | React Virtuoso
The rangeChanged callback property gets called with the start/end indexes of the visible range. Note: the rangeChanged reports the rendered items, ...
Read more >
react-virtuoso: Versions - Openbase
A change which makes the component CSP compliant (#77); Port of rangeChanged to the GroupedVirtuoso component variant. (#81) ...
Read more >
Support for sticky items,about petyosi/react-virtuoso - GithubHelp
Just published v0.3.0 that includes a GroupedVirtuoso component that supports sticky group ... [BUG] Wrong startIndex and endIndex rangeChanged callback in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found