Dynamic row height not working in Grid
See original GitHub issueDescribe the bug
When cells within each row have varying size content, I would expect the height of the row (and in turn each cell) to be the height of the largest cell in the row. However, it seems that this is not working, unless I’m doing something incorrectly. I’ve read through several issues related to dynamically sizing rows (https://github.com/TanStack/virtual/issues/376, https://github.com/TanStack/virtual/issues/235, https://github.com/TanStack/virtual/issues/28) but they are all either out-dated, closed without resolution, or not quite the same use case. In the codesandbox example, i’m virtualizing the columns but forcing them all to render in order to illustrate this issue. You can see that each cell within the row is measured correctly according to the content, but I think the height of each cell should be adjusted to account for the maximum cell height, right?
Your minimal, reproducible example
https://codesandbox.io/s/window-scroll-virtualized-ltfdib?file=/src/main.tsx
Steps to reproduce
- See the codesandbox repro
Expected behavior
Height of each cell should be Math.max(...cellHeights)
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: macOs
- Browser: Chrome 107
tanstack-virtual version
3.0.0-beta.23
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
- I agree to follow this project’s Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Issue Analytics
- State:
- Created 10 months ago
- Comments:12
@jamesonhill maybe go with a bit different approach, first position rows, then render columns as one block, thanks to minHeight: row.size + ResizeObserver there is no need for custom measureElementMaxSize to store max size.
Checkout this https://codesandbox.io/s/window-scroll-virtualized-forked-pzebvz?file=/src/main.tsx
@piecyk Brilliant. Thanks a ton for your help. This could be a good example to add to the documentation. Maybe i’ll add a PR for it, but will close this issue.