Allow for extra padding in the header #856
-
Hi, I am often encountering designs, which require some form of header before a table, where the header is part of the scrollable area. When trying to virtualize the rows of the table below this header, the TanStack Virtual counts the header height into the range of which rows should be visible, causing hiding of rows, which are still visible. So far I have been using the Here is a repro: https://tanstackvirtualn4fmgh-y3ym--5173--134daa3c.local-credentialless.webcontainer.io/ Notes around current options
Potential workarounds
Some suggestions how it could be implemented
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
So, the main issue here is probably that my list uses relative position, therefore all rows are positioned from the list rather from the top of the scroll element, moving the |
Beta Was this translation helpful? Give feedback.
-
I faced the same issue, posted workaround on my discussion, here: It is not that fancy as it could be, but at least it works fine |
Beta Was this translation helpful? Give feedback.
-
@alesmenzel @Wordllban for this cases the https://stackblitz.com/edit/tanstack-virtual-ffmfj3?file=src%2Fmain.tsx,package.json&preset=node |
Beta Was this translation helpful? Give feedback.
-
Great answer. What I ended up doing based on @piecyk ´s solution is to get the list´s offset from top of the scroll area and use that -> that way I don't need to change the calculation in case I decide to add another element into the header. Would definitely deserve a mention in the docs thought 👍 |
Beta Was this translation helpful? Give feedback.
-
Created a pull request to update docs. I would be happy to get feedback from you guys |
Beta Was this translation helpful? Give feedback.
@alesmenzel @Wordllban for this cases the
scrollMargin
options should be use, as the elements should be position in context of container we need to subtract this value from start.https://stackblitz.com/edit/tanstack-virtual-ffmfj3?file=src%2Fmain.tsx,package.json&preset=node