petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.16k stars 299 forks source link

[BUG] `VirtuosoMockContext` not working in conjunction with `initialTopMostItemIndex` #1001

Open mstykow opened 10 months ago

mstykow commented 10 months ago

Describe the bug Using VirtuosoMockContext to test components using Virtuoso fails as soon as initialTopMostItemIndex is set to something other than undefined or 0.

Reproduction

  1. Open this Sandbox: https://codesandbox.io/p/sandbox/heuristic-morning-87qd4l
  2. Run yarn test in a terminal.
  3. Note that tests are failing.
  4. Comment out the line involving initialTopMostItemIndex.
  5. Notice tests are passing.

Expected behavior VirtuosoMockContext works even when initialTopMostItemIndex is set.

Additional context react 18.2.0 react-virtuoso 4.6.2

petyosi commented 10 months ago

Happy to accept a PR on the matter.