@@ -236,15 +236,28 @@ const UITable: FC<TableProps & IExtendableTable & IComponentConstants> = (props)
236236 const updateRowHeight = useCallback ( ( ) => {
237237 clearTimeout ( updateRowHeightTimeout . current ) ;
238238 updateRowHeightTimeout . current = window . setTimeout ( ( ) => {
239- let max = 0 ;
240- for ( let v of cellHeights . current . values ( ) ) {
241- max = Math . max ( max , v ) ;
239+ if ( props . sameRowHeight === false && ! props . rowHeight ) {
240+ let sum = 0 ;
241+ for ( let v of cellHeights . current . values ( ) ) {
242+ sum += v ;
243+ }
244+ const mean = Math . ceil ( sum / cellHeights . current . size ) ;
245+ setRowHeight ( negotiateRowHeight (
246+ props . minRowHeight ,
247+ mean ,
248+ props . maxRowHeight
249+ ) ) ;
250+ } else {
251+ let max = 0 ;
252+ for ( let v of cellHeights . current . values ( ) ) {
253+ max = Math . max ( max , v ) ;
254+ }
255+ setRowHeight ( negotiateRowHeight (
256+ props . minRowHeight ,
257+ max ,
258+ props . maxRowHeight
259+ ) ) ;
242260 }
243- setRowHeight ( negotiateRowHeight (
244- props . minRowHeight ,
245- max ,
246- props . maxRowHeight
247- ) ) ;
248261 } , 1 ) ;
249262 } , [ props . maxRowHeight ] )
250263
@@ -1030,7 +1043,7 @@ const UITable: FC<TableProps & IExtendableTable & IComponentConstants> = (props)
10301043 const isEditable = getCellIsEditable ( rowData ) ;
10311044 const elementRef = useRef < any > ( null ) ;
10321045 useEffect ( ( ) => {
1033- if ( tableInfo . rowIndex < 100 && props . sameRowHeight && ! props . rowHeight ) {
1046+ if ( tableInfo . rowIndex < 100 && ( props . sameRowHeight === true || props . sameRowHeight === false ) && ! props . rowHeight ) {
10341047 const h = ( elementRef . current ?. querySelector ( '.cell-data-content' ) . scrollHeight ?? 0 ) + 8 ;
10351048 const k = `${ colName } -${ tableInfo . rowIndex } ` ;
10361049 cellHeights . current . set ( k , h ) ;
@@ -1546,9 +1559,12 @@ const UITable: FC<TableProps & IExtendableTable & IComponentConstants> = (props)
15461559 ref = { tableRef }
15471560 style = { {
15481561 "--table-data-height" : `${ rowHeight - 8 } px` ,
1562+ ...( props . minRowHeight ? { "--table-data-min-height" : `${ props . minRowHeight - 8 } px` } : { } ) ,
1563+ ...( props . maxRowHeight ? { "--table-data-max-height" : `${ props . maxRowHeight - 8 } px` } : { } ) ,
15491564 } as React . CSSProperties }
15501565 className = { concatClassnames (
15511566 "rc-table" ,
1567+ props . sameRowHeight === false && ! props . rowHeight ? "variable-row-height" : '' ,
15521568 props . autoResize === false ? "no-auto-resize" : "" ,
15531569 getNavTableClassName ( props . parent ) ,
15541570 props . styleClassNames
0 commit comments