fix(table): sticky header & content placement in virtualized table (#5184)

* fix(table): header sticky in virtualized table + topContent and bottom content placement fix

* fix(table): header sticky in virtualized table PR return

* chore(changeset): revise changeset msg

---------

Co-authored-by: աӄա <wingkwong.code@gmail.com>
This commit is contained in:
Hova25 2025-04-19 17:27:05 +02:00 committed by GitHub
parent 531518f2ef
commit 8bd878341e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 73 additions and 56 deletions

View File

@ -0,0 +1,5 @@
---
"@heroui/table": patch
---
fix(table): Header sticky in virtualized table + topContent and bottom content placement fix in virtualized table (#5149)

View File

@ -81,16 +81,22 @@ const VirtualizedTable = forwardRef<"table", TableProps>((props, ref) => {
overscan: 5,
});
const tableProps = getTableProps();
return (
<div {...getBaseProps()}>
{/* We need to add p-1 to make the shadow-sm visible */}
{topContentPlacement === "outside" && topContent}
<Wrapper>
<>
{topContentPlacement === "outside" && topContent}
<div style={{height: `calc(${rowVirtualizer.getTotalSize() + headerHeight}px)`}}>
<>
{topContentPlacement === "inside" && topContent}
<Component {...getTableProps()}>
<Component
{...tableProps}
style={{
height: `calc(${rowVirtualizer.getTotalSize() + headerHeight}px)`,
...tableProps.style,
}}
>
<TableRowGroup ref={headerRef} classNames={values.classNames} slots={values.slots}>
{collection.headerRows.map((headerRow) => (
<TableHeaderRow
@ -142,10 +148,8 @@ const VirtualizedTable = forwardRef<"table", TableProps>((props, ref) => {
</Component>
{bottomContentPlacement === "inside" && bottomContent}
</>
</div>
{bottomContentPlacement === "outside" && bottomContent}
</>
</Wrapper>
{bottomContentPlacement === "outside" && bottomContent}
</div>
);
});

View File

@ -1160,6 +1160,14 @@ export const Virtualized = {
},
};
export const VirtualizedWithHeaderSticky = {
...Virtualized,
args: {
...Virtualized.args,
isHeaderSticky: true,
},
};
export const TenThousandRows = {
render: VirtualizedTemplate,
args: {

View File

@ -55,7 +55,7 @@ const table = tv({
],
table: "min-w-full h-auto",
thead: "[&>tr]:first:rounded-lg",
tbody: "",
tbody: "after:block",
tr: ["group/tr", "outline-none", ...dataFocusVisibleClasses],
th: [
"group/th",