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 5448982
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 12 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,8 @@ 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
"relative w-full",
"scrollbar-thin h-[80dvh] overflow-auto", // Set a fixed height for the container
"bg-background border-subtle rounded-lg border",
containerClassName
)}
Expand Down Expand Up @@ -306,7 +307,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
6 changes: 2 additions & 4 deletions packages/features/data-table/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { classNames as cn } from "@calcom/lib";

const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(
({ className, ...props }, ref) => (
<div className="relative w-full overflow-auto">
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
</div>
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
)
);
Table.displayName = "Table";
Expand All @@ -18,7 +16,7 @@ TableHeader.displayName = "TableHeader";

const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(
({ className, ...props }, ref) => (
<tbody ref={ref} className={cn("[&_tr:last-child]:border-0", className)} {...props} />
<tbody ref={ref} className={cn("grid", "[&_tr:last-child]:border-0", className)} {...props} />
)
);
TableBody.displayName = "TableBody";
Expand Down

0 comments on commit 5448982

Please sign in to comment.