Difficulty with table
See original GitHub issueI have a table with fixed headers and a scrolling body. I implemented this by putting the following on tbody
:
.cf-document-list-body {
display: block;
max-height: 65vh;
overflow: auto;
}
I would like to use ReactList
to render the rows of this table.
In my itemsRenderer
, I have:
return <table>
<HeaderRow columns={columns} headerClassName={headerClassName}/>
<tbody className={bodyClassName} ref={ref}>
{renderedItems}
</tbody>
<FooterRow columns={columns} />
</table>;
I am passing scrollParentGetter
to be a function that returns the tbody
ref.
This produces the following HTML:
<div style="position: relative; height: 75511px;">
<div style="transform: translate(0px, 0px);">
<table>
<!-- table contents are correct -->
</table>
</div>
</div>
This messes up my scrolling, and produces a giant div
on the page that’s 75511px
tall. I think that what needs to happen is the two wrapper div
s need to be in the element that has fixed height. In my case, that’s the tbody
, but it’s invalid HTML to put div
s in a tbody
.
I’m doing this for an open-source project, in case you want to see the full code: https://github.com/department-of-veterans-affairs/caseflow/pull/2019.
I’m not sure what the best way to fix this is. Why is it necessary to use these two wrapper div
s? Why not just throw everything in the tbody
, and then just add and remove elements according to their visibility, as determined by looking the tbody
scroll and bounding rect attributes?
Or is there a different way you’d envisioned people doing this with tables?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Actually, would you be amenable to a PR to implement this functionality? Instead of the
div
s for spacing, it would use something like:I’ve been working on this a bit, but it is not ready to show off yet.
I am not using
position: fixed
, so I can’t help you there.