@@ -23,8 +23,6 @@ interface ExtendedColumn {
2323 data : any [ ]
2424}
2525
26- const MAXIMUM_ESTIMATED_ROW_HEIGHT = 42
27-
2826/*
2927 * @param result - the result of the query
3028 * @param paginationOffset - the start index of the first row of the current page
@@ -40,24 +38,24 @@ const getNumberOfRowsOnCurrentPage = (
4038 headerHeight : number ,
4139 rowHeight : number
4240) : number => {
43- if ( totalAvailableHeight == = 0 ) {
41+ if ( totalAvailableHeight < = 0 ) {
4442 return 0
4543 }
4644
47- const minimumLength = result ?. table ?. length ?? 1
48- const estimatedRowHeight = Math . min (
49- Math . ceil ( totalAvailableHeight / minimumLength ) ,
50- MAXIMUM_ESTIMATED_ROW_HEIGHT
51- )
52- const visibleRowHeight = Math . max ( rowHeight , estimatedRowHeight )
45+ // this means that no rows have been mounted or measured, so we need to
46+ // mount one row to measure the row height
47+ if ( rowHeight <= 0 ) {
48+ return 1
49+ }
5350
5451 let runningHeight = 14
5552 let rowIdx = paginationOffset
5653 let currentTable
5754 let lastSignature
5855 let signature
5956
60- const lastVisibleRowMinimumHeight = 0.2 * visibleRowHeight
57+ // rowHeight is now guaranteed to be greater than zero
58+ const lastVisibleRowMinimumHeight = 0.2 * rowHeight
6159
6260 while ( rowIdx < result . table . length ) {
6361 if ( result . table . columns ?. table ?. data ?. [ rowIdx ] !== currentTable ) {
@@ -92,7 +90,7 @@ const getNumberOfRowsOnCurrentPage = (
9290 continue
9391 }
9492
95- runningHeight += visibleRowHeight
93+ runningHeight += rowHeight
9694
9795 if ( runningHeight + lastVisibleRowMinimumHeight >= totalAvailableHeight ) {
9896 break
@@ -402,7 +400,7 @@ const PagedTable: FC<Props> = ({result, showAll}) => {
402400 numberOfRowsOnCurrentPage ,
403401 showAll
404402 ) ,
405- [ numberOfRowsOnCurrentPage , paginationOffset , result ] // eslint-disable-line react-hooks/exhaustive-deps
403+ [ numberOfRowsOnCurrentPage , paginationOffset , result , showAll ]
406404 )
407405
408406 const inner = useMemo ( ( ) => {
0 commit comments