@@ -88,7 +88,8 @@ class BaseTable extends React.PureComponent {
8888 this . _handleColumnResizeStart = this . _handleColumnResizeStart . bind ( this ) ;
8989 this . _handleColumnResizeStop = this . _handleColumnResizeStop . bind ( this ) ;
9090 this . _handleColumnSort = this . _handleColumnSort . bind ( this ) ;
91- this . _handleRowHeightMeasured = this . _handleRowHeightMeasured . bind ( this ) ;
91+ this . _handleFrozenRowHeightChange = this . _handleFrozenRowHeightChange . bind ( this ) ;
92+ this . _handleRowHeightChange = this . _handleRowHeightChange . bind ( this ) ;
9293
9394 this . _getLeftTableContainerStyle = memoize ( getContainerStyle ) ;
9495 this . _getRightTableContainerStyle = memoize ( getContainerStyle ) ;
@@ -118,20 +119,13 @@ class BaseTable extends React.PureComponent {
118119 this . _rightRowHeightMap = { } ;
119120 this . _getRowHeight = this . _getRowHeight . bind ( this ) ;
120121 this . _updateRowHeights = debounce ( ( ) => {
121- if (
122- Object . keys ( this . _rowHeightMapBuffer ) . some ( key => this . _rowHeightMapBuffer [ key ] !== this . _rowHeightMap [ key ] )
123- ) {
124- this . _isResetting = true ;
125- this . _rowHeightMap = { ...this . _rowHeightMap , ...this . _rowHeightMapBuffer } ;
126- this . resetAfterRowIndex ( this . _resetIndex , false ) ;
127- this . _rowHeightMapBuffer = { } ;
128- this . _resetIndex = null ;
129- this . forceUpdateTable ( ) ;
130- this . _isResetting = false ;
131- } else {
132- this . _rowHeightMapBuffer = { } ;
133- this . _resetIndex = null ;
134- }
122+ this . _isResetting = true ;
123+ this . _rowHeightMap = { ...this . _rowHeightMap , ...this . _rowHeightMapBuffer } ;
124+ this . resetAfterRowIndex ( this . _resetIndex , false ) ;
125+ this . _rowHeightMapBuffer = { } ;
126+ this . _resetIndex = null ;
127+ this . forceUpdateTable ( ) ;
128+ this . _isResetting = false ;
135129 } , 0 ) ;
136130
137131 this . _scroll = { scrollLeft : 0 , scrollTop : 0 } ;
@@ -216,23 +210,13 @@ class BaseTable extends React.PureComponent {
216210 * Reset cached row heights after a specific rowIndex, should be used only in dynamic mode(estimatedRowHeight is provided)
217211 */
218212 resetAfterRowIndex ( rowIndex = 0 , shouldForceUpdate = true ) {
213+ if ( ! this . props . estimatedRowHeight ) return ;
214+
219215 this . table && this . table . resetAfterRowIndex ( rowIndex , shouldForceUpdate ) ;
220216 this . leftTable && this . leftTable . resetAfterRowIndex ( rowIndex , shouldForceUpdate ) ;
221217 this . rightTable && this . rightTable . resetAfterRowIndex ( rowIndex , shouldForceUpdate ) ;
222218 }
223219
224- /**
225- * Reset cached row heights, should be used only in dynamic mode(estimatedRowHeight is provided)
226- */
227- resetRowHeightCache ( ) {
228- this . _resetIndex = null ;
229- this . _rowHeightMap = { } ;
230- this . _rowHeightMapBuffer = { } ;
231- this . _mainRowHeightMap = { } ;
232- this . _leftRowHeightMap = { } ;
233- this . _rightRowHeightMap = { } ;
234- }
235-
236220 /**
237221 * Scroll to the specified offset.
238222 * Useful for animating position changes.
@@ -334,6 +318,7 @@ class BaseTable extends React.PureComponent {
334318 [ this . _prefixClass ( 'row--customized' ) ] : rowRenderer ,
335319 } ) ;
336320
321+ const hasFrozenColumns = this . columnManager . hasFrozenColumns ( ) ;
337322 const rowProps = {
338323 ...extraProps ,
339324 role : 'row' ,
@@ -356,8 +341,8 @@ class BaseTable extends React.PureComponent {
356341 expandIconRenderer : this . renderExpandIcon ,
357342 onRowExpand : this . _handleRowExpand ,
358343 // for fixed table, we need to sync the hover state across the inner tables
359- onRowHover : this . columnManager . hasFrozenColumns ( ) ? this . _handleRowHover : null ,
360- onRowHeightMeasured : this . _handleRowHeightMeasured ,
344+ onRowHover : hasFrozenColumns ? this . _handleRowHover : null ,
345+ onRowHeightChange : hasFrozenColumns ? this . _handleFrozenRowHeightChange : this . _handleRowHeightChange ,
361346 } ;
362347
363348 return < TableRow { ...rowProps } /> ;
@@ -688,7 +673,7 @@ class BaseTable extends React.PureComponent {
688673
689674 const _data = expandColumnKey ? this . _flattenOnKeys ( data , this . getExpandedRowKeys ( ) , this . props . rowKey ) : data ;
690675 if ( this . _data !== _data ) {
691- this . resetRowHeightCache ( ) ;
676+ this . _resetRowHeightCache ( ) ;
692677 this . _data = _data ;
693678 }
694679 // should be after `this._data` assigned
@@ -977,32 +962,44 @@ class BaseTable extends React.PureComponent {
977962 onColumnSort ( { column, key, order } ) ;
978963 }
979964
980- _handleRowHeightMeasured ( rowKey , size , rowIndex , frozen ) {
981- if ( this . _resetIndex === null ) this . _resetIndex = rowIndex ;
982- else if ( this . _resetIndex > rowIndex ) this . _resetIndex = rowIndex ;
965+ _handleFrozenRowHeightChange ( rowKey , size , rowIndex , frozen ) {
966+ if ( ! frozen ) {
967+ this . _mainRowHeightMap [ rowKey ] = size ;
968+ } else if ( frozen === FrozenDirection . RIGHT ) {
969+ this . _rightRowHeightMap [ rowKey ] = size ;
970+ } else {
971+ this . _leftRowHeightMap [ rowKey ] = size ;
972+ }
983973
984- if ( this . columnManager . hasFrozenColumns ( ) ) {
985- if ( ! frozen ) {
986- this . _mainRowHeightMap [ rowKey ] = size ;
987- } else if ( frozen === FrozenDirection . RIGHT ) {
988- this . _rightRowHeightMap [ rowKey ] = size ;
989- } else {
990- this . _leftRowHeightMap [ rowKey ] = size ;
991- }
974+ const height = Math . max (
975+ this . _mainRowHeightMap [ rowKey ] || 0 ,
976+ this . _leftRowHeightMap [ rowKey ] || 0 ,
977+ this . _rightRowHeightMap [ rowKey ] || 0
978+ ) ;
992979
993- this . _rowHeightMapBuffer [ rowKey ] = Math . max (
994- this . _mainRowHeightMap [ rowKey ] || 0 ,
995- this . _leftRowHeightMap [ rowKey ] || 0 ,
996- this . _rightRowHeightMap [ rowKey ] || 0
997- ) ;
998- } else {
999- if ( ! this . _rowHeightMap [ rowKey ] || this . _rowHeightMap [ rowKey ] !== size ) {
1000- this . _rowHeightMapBuffer [ rowKey ] = size ;
1001- }
980+ if ( this . _rowHeightMap [ rowKey ] !== height ) {
981+ this . _handleRowHeightChange ( rowKey , height , rowIndex ) ;
1002982 }
983+ }
984+
985+ _handleRowHeightChange ( rowKey , size , rowIndex ) {
986+ if ( this . _resetIndex === null ) this . _resetIndex = rowIndex ;
987+ else if ( this . _resetIndex > rowIndex ) this . _resetIndex = rowIndex ;
1003988
989+ this . _rowHeightMapBuffer [ rowKey ] = size ;
1004990 this . _updateRowHeights ( ) ;
1005991 }
992+
993+ _resetRowHeightCache ( ) {
994+ if ( ! this . props . estimatedRowHeight ) return ;
995+
996+ this . _resetIndex = null ;
997+ this . _rowHeightMapBuffer = { } ;
998+ this . _rowHeightMap = { } ;
999+ this . _mainRowHeightMap = { } ;
1000+ this . _leftRowHeightMap = { } ;
1001+ this . _rightRowHeightMap = { } ;
1002+ }
10061003}
10071004
10081005BaseTable . Column = Column ;
0 commit comments