@@ -75,11 +75,7 @@ function ResizeableTableComp<RecordType extends object>(
75
75
76
76
const [ resizeData , setResizeData ] = useState ( { index : - 1 , width : - 1 } ) ;
77
77
const tableRef = useRef < HTMLDivElement > ( null ) ;
78
- const [ measuredHeights , setMeasuredHeights ] = useState < {
79
- header : number ;
80
- summary : number ;
81
- bodyContent : number ;
82
- } > ( { header : 0 , summary : 0 , bodyContent : 0 } ) ;
78
+
83
79
84
80
const handleResize = useCallback ( ( width : number , index : number ) => {
85
81
setResizeData ( { index, width } ) ;
@@ -178,30 +174,7 @@ function ResizeableTableComp<RecordType extends object>(
178
174
} ) ;
179
175
} , [ columns , resizeData , createCellHandler , createHeaderCellHandler ] ) ;
180
176
181
- // Measure header, summary & body content heights so we can derive the body viewport height for vertical scrolling
182
- useEffect ( ( ) => {
183
- if ( ! isFixedHeight || ! tableRef . current ) return ;
184
- const tableEl = tableRef . current ;
185
-
186
- const measure = ( ) => {
187
- const headerH =
188
- ( tableEl . querySelector ( ".ant-table-header" ) as HTMLElement )
189
- ?. clientHeight ?? 0 ;
190
- const summaryH =
191
- ( tableEl . querySelector ( ".ant-table-summary" ) as HTMLElement )
192
- ?. clientHeight ?? 0 ;
193
- const bodyContentH =
194
- ( tableEl . querySelector ( ".ant-table-tbody" ) as HTMLElement )
195
- ?. scrollHeight ?? 0 ;
196
- setMeasuredHeights ( { header : headerH , summary : summaryH , bodyContent : bodyContentH } ) ;
197
- } ;
198
-
199
- measure ( ) ;
200
- const resizeObserver = new ResizeObserver ( measure ) ;
201
- resizeObserver . observe ( tableEl ) ;
202
-
203
- return ( ) => resizeObserver . disconnect ( ) ;
204
- } , [ isFixedHeight , dataSource ?. length , columns . length ] ) ;
177
+
205
178
206
179
// Sum widths (including resized values) to keep horizontal scroll baseline accurate
207
180
function getTotalTableWidth (
@@ -222,47 +195,17 @@ function ResizeableTableComp<RecordType extends object>(
222
195
223
196
const scrollAndVirtualizationSettings = useMemo ( ( ) => {
224
197
const totalWidth = getTotalTableWidth ( memoizedColumns as any , resizeData ) ;
225
- const scrollSettings : { x ?: number ; y ?: number } = { x : totalWidth } ;
226
-
227
- // For fixed height mode, set vertical scroll height (body viewport height)
228
- if ( isFixedHeight && containerHeight && containerHeight > 0 ) {
229
- const availableHeight = Math . max (
230
- containerHeight - measuredHeights . header - measuredHeights . summary ,
231
- 200
232
- ) ;
233
-
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
- }
253
-
198
+ const shouldVirtualize = isFixedHeight && ( dataSource ?. length ?? 0 ) >= 50 ;
199
+
254
200
return {
255
- virtual : false ,
256
- scroll : scrollSettings ,
201
+ virtual : shouldVirtualize ,
202
+ scroll : {
203
+ x : totalWidth ,
204
+ // FIX: Set y for ANY fixed height mode, not just virtualization
205
+ y : isFixedHeight && containerHeight ? containerHeight : undefined
206
+ }
257
207
} ;
258
- } , [
259
- isFixedHeight ,
260
- containerHeight ,
261
- dataSource ?. length ,
262
- measuredHeights ,
263
- memoizedColumns ,
264
- resizeData ,
265
- ] ) ;
208
+ } , [ isFixedHeight , containerHeight , dataSource ?. length , memoizedColumns , resizeData ] ) ;
266
209
267
210
return (
268
211
< StyledTableWrapper ref = { tableRef } >
0 commit comments