petyosi / react-virtuoso

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

[BUG] - Does not render the correct number of items with svg/rect elements #973

Closed vaasu-dhand-als closed 1 year ago

vaasu-dhand-als commented 1 year ago

Describe the bug I am trying to create a vertical svg strip with the rect elements virtualized based on the parent component's scroll position. I spent quite a lot of time implementing a solution, but could not come up with one. I have noticed the following issues while working with svg elements:

  1. The List component does not render the correct number of items. It only renders one item, even though the totalCount is clearly greater than 1.
  2. Even if I see the correct number of nodes in the browser elements pane. The virtualization does not work.

Reproduction Codesandbox

To Reproduce Steps to reproduce the behavior:

  1. Go to the above link
  2. Open the browser's elements pane and notice only one rect element being rendered inside the svg tag

Expected behavior Expected behaviour is to see the correct number of rect elements and the virtualization to work.

Screenshots

image

Desktop (please complete the following information):

Additional context

petyosi commented 1 year ago

Your custom Item implementation is incorrect, as you don't pass the necessary data props down to the actual element.

Even with that fixed, however, the scenario does not work. I can see errors regarding the measurement of the items resolving to zero, which is incorrect. Not sure if resize observing works with SVG at all.

I have no capacity to investigate this scenario further, it's also a fairly niche one. Happy to accept a reasonable PR if you're willing to dig down and figure out what's going on.