@@ -78,7 +78,8 @@ function ResizeableTableComp<RecordType extends object>(
7878 const [ measuredHeights , setMeasuredHeights ] = useState < {
7979 header : number ;
8080 summary : number ;
81- } > ( { header : 0 , summary : 0 } ) ;
81+ bodyContent : number ;
82+ } > ( { header : 0 , summary : 0 , bodyContent : 0 } ) ;
8283
8384 const handleResize = useCallback ( ( width : number , index : number ) => {
8485 setResizeData ( { index, width } ) ;
@@ -177,7 +178,7 @@ function ResizeableTableComp<RecordType extends object>(
177178 } ) ;
178179 } , [ columns , resizeData , createCellHandler , createHeaderCellHandler ] ) ;
179180
180- // Measure header & summary heights so we can derive the body viewport height for vertical scrolling
181+ // Measure header, summary & body content heights so we can derive the body viewport height for vertical scrolling
181182 useEffect ( ( ) => {
182183 if ( ! isFixedHeight || ! tableRef . current ) return ;
183184 const tableEl = tableRef . current ;
@@ -189,7 +190,10 @@ function ResizeableTableComp<RecordType extends object>(
189190 const summaryH =
190191 ( tableEl . querySelector ( ".ant-table-summary" ) as HTMLElement )
191192 ?. clientHeight ?? 0 ;
192- setMeasuredHeights ( { header : headerH , summary : summaryH } ) ;
193+ const bodyContentH =
194+ ( tableEl . querySelector ( ".ant-table-tbody" ) as HTMLElement )
195+ ?. scrollHeight ?? 0 ;
196+ setMeasuredHeights ( { header : headerH , summary : summaryH , bodyContent : bodyContentH } ) ;
193197 } ;
194198
195199 measure ( ) ;
@@ -226,19 +230,29 @@ function ResizeableTableComp<RecordType extends object>(
226230 containerHeight - measuredHeights . header - measuredHeights . summary ,
227231 200
228232 ) ;
229- scrollSettings . y = availableHeight ;
230- }
231233
232- // Enable virtualization for fixed height mode with 50+ rows
233- const shouldUseVirtualization = Boolean (
234- isFixedHeight &&
235- containerHeight &&
236- dataSource ?. length &&
237- dataSource . length >= 50
238- ) ;
234+ // Enable virtualization for fixed height mode with 50+ rows
235+ const shouldUseVirtualization = Boolean (
236+ isFixedHeight &&
237+ containerHeight &&
238+ dataSource ?. length &&
239+ dataSource . length >= 50
240+ ) ;
241+
242+ // Only set scroll.y if virtualization is on OR content actually overflows
243+ const contentOverflows = measuredHeights . bodyContent > availableHeight ;
244+ if ( shouldUseVirtualization || contentOverflows ) {
245+ scrollSettings . y = availableHeight ;
246+ }
247+
248+ return {
249+ virtual : shouldUseVirtualization ,
250+ scroll : scrollSettings ,
251+ } ;
252+ }
239253
240254 return {
241- virtual : shouldUseVirtualization ,
255+ virtual : false ,
242256 scroll : scrollSettings ,
243257 } ;
244258 } , [
0 commit comments