Skip to content

Commit

Permalink
fix infinite scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee committed Jan 21, 2025
1 parent 3697240 commit 9a1d51a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/features/data-table/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export function DataTable<TData, TValue>({
ref={tableContainerRef}
onScroll={onScroll}
className={classNames(
"scrollbar-thin overflow-auto [&>div]:h-[80dvh]", // Set a fixed height for the container
"scrollbar-thin [&>div]:h-[80dvh]", // Set a fixed height for the container
"bg-background border-subtle rounded-lg border",
containerClassName
)}
Expand Down Expand Up @@ -306,7 +306,16 @@ function DataTableBody<TData>({
key={row.id}
data-index={virtualRow.index} //needed for dynamic row height measurement
data-state={row.getIsSelected() && "selected"}
className="has-[[data-state=selected]]:bg-muted/50"
style={{
display: "flex",
position: "absolute",
transform: `translateY(${virtualRow.start}px)`, //this should always be a `style` as it changes on scroll
width: "100%",
}}
className={classNames(
onRowMouseclick && "hover:cursor-pointer",
"has-[[data-state=selected]]:bg-muted/50 group"
)}
onClick={() => onRowMouseclick && onRowMouseclick(row)}>
{row.getVisibleCells().map((cell) => {
const column = table.getColumn(cell.column.id);
Expand Down

0 comments on commit 9a1d51a

Please sign in to comment.