Skip to content

Commit c939c32

Browse files
Lukas742MarcusNotheis
authored andcommitted
feat(AnalyticalTable): Add overscanCount prop (#231)
1 parent c8836fb commit c939c32

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export interface TableProps extends CommonProps {
100100
subRowsKey?: string;
101101
selectedRowKey?: string;
102102
isTreeTable?: boolean;
103+
overscanCount?: number;
103104

104105
// default components
105106

@@ -138,7 +139,8 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
138139
visibleRows,
139140
minRows,
140141
isTreeTable,
141-
alternateRowColor
142+
alternateRowColor,
143+
overscanCount
142144
} = props;
143145
const theme = useTheme() as JSSTheme;
144146
const classes = useStyles({ rowHeight: props.rowHeight });
@@ -308,6 +310,7 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
308310
tableBodyHeight={tableBodyHeight}
309311
visibleRows={visibleRows}
310312
alternateRowColor={alternateRowColor}
313+
overscanCount={overscanCount}
311314
/>
312315
)}
313316
</div>

packages/main/src/components/AnalyticalTable/virtualization/VirtualTableBody.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export const VirtualTableBody = (props) => {
2323
internalRowHeight,
2424
tableBodyHeight,
2525
visibleRows,
26-
alternateRowColor
26+
alternateRowColor,
27+
overscanCount
2728
} = props;
2829

2930
const innerDivRef = useRef(null);
@@ -39,7 +40,7 @@ export const VirtualTableBody = (props) => {
3940
}, [innerDivRef.current, selectable, classes.tbody, classes.selectable]);
4041

4142
const itemCount = Math.max(minRows, rows.length);
42-
const overscanCount = Math.floor(visibleRows / 2);
43+
const overscan = overscanCount ? overscanCount : Math.floor(visibleRows / 2);
4344

4445
const columnsWidth = useMemo(() => {
4546
const aggregatedWidth = columns
@@ -104,7 +105,7 @@ export const VirtualTableBody = (props) => {
104105
itemSize={internalRowHeight}
105106
itemKey={getItemKey}
106107
innerRef={innerDivRef}
107-
overscanCount={overscanCount}
108+
overscanCount={overscan}
108109
>
109110
{VirtualTableRow}
110111
</FixedSizeList>

0 commit comments

Comments
 (0)