Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/components/VirtualTable/index.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
background: #f5f3f5;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
overflow: visible !important;
}

.table :global(.ReactVirtualized__Table__headerColumn) {
Expand All @@ -62,18 +63,30 @@
align-self: baseline;
justify-content: start;
width: 100%;
overflow: visible;
overflow: visible !important;
white-space: nowrap;
text-align: left;
text-overflow: ellipsis;
position: relative;
}

.table :global(.ReactVirtualized__Table__headerTruncatedText) {
display: contents;
}

.headerContent {
display: flex;
align-items: center;
width: 100%;
min-width: 0;
}

.headerActions {
display: flex;
align-items: center;
flex-shrink: 0;
gap: 2px;
margin-left: auto;
}

.headerParagraph {
Expand Down Expand Up @@ -109,16 +122,12 @@

.table :global(.ReactVirtualized__Table__rowColumn) {
padding: 13px 0px;
}

.table :global(.ReactVirtualized__Table__rowColumn:last-of-type),
.table :global(.ReactVirtualized__Table__headerColumn:last-of-type) {
padding-right: 16px;
overflow: visible !important;
}

.table :global(.ReactVirtualized__Table__rowColumn:first-of-type),
.table :global(.ReactVirtualized__Table__headerColumn:first-of-type) {
margin-left: 8px;
margin-left: 4px;
}

.table :global(.ReactVirtualized__Table__Grid) {
Expand Down
14 changes: 9 additions & 5 deletions src/components/VirtualTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import type { FC, ReactNode } from "react";
import type { MenuProps } from "antd";

const COL_WIDTH = 200;
const INDEX_COL_WIDTH = 70;
const INDEX_COL_WIDTH = 80;
const MIN_COL_WIDTH = 100;
const PX_PER_CHAR = 8;
const HEADER_PADDING = 32;
Expand Down Expand Up @@ -333,7 +333,7 @@ const VirtualTable: FC<VirtualTableProps> = ({
const dataKey = (columnData as any).dataKey ?? columnId;

return (
<>
<div className={styles.headerContent}>
<Tooltip title={tooltipTitle}>
<Paragraph ellipsis className={styles.headerParagraph}>
{shortLabel}
Expand All @@ -360,7 +360,7 @@ const VirtualTable: FC<VirtualTableProps> = ({
<HolderOutlined />
</div>
</div>
</>
</div>
);
};

Expand Down Expand Up @@ -438,10 +438,11 @@ const VirtualTable: FC<VirtualTableProps> = ({
};

const isEmpty = !columns.length && !rows.length;
const TABLE_PADDING = 40;
const tableWidth = useMemo(() => {
let tw = flatHeaders.reduce((sum, col) => sum + getColumnWidth(col.id), 0);
if (!hideIndexColumn) tw += INDEX_COL_WIDTH;
return tw;
return tw + TABLE_PADDING;
}, [flatHeaders, getColumnWidth, hideIndexColumn]);

const wrapperWidth = wrapperRef.current?.clientWidth || width;
Expand Down Expand Up @@ -493,7 +494,10 @@ const VirtualTable: FC<VirtualTableProps> = ({
id={tableId}
className={cn(styles.table, tableId && styles.minWidth)}
width={effectiveTableWidth}
height={height}
height={
headerHeight +
Math.floor((height - headerHeight) / rowHeight) * rowHeight
}
headerHeight={headerHeight}
rowHeight={rowHeight}
rowCount={rows.length}
Expand Down