@@ -347,31 +347,61 @@ export default function lock(BaseComponent) {
347
347
}
348
348
}
349
349
350
+ removeLockTable ( ) {
351
+ const lockLeftLen = this . lockLeftChildren . length ;
352
+ const lockRightLen = this . lockRightChildren . length ;
353
+
354
+ if ( lockLeftLen ) {
355
+ this . _notNeedAdjustLockLeft = true ;
356
+ }
357
+ if ( lockRightLen ) {
358
+ this . _notNeedAdjustLockRight = true ;
359
+ }
360
+ if ( lockRightLen || lockLeftLen ) {
361
+ this . forceUpdate ( ) ;
362
+ return true ;
363
+ }
364
+ }
365
+
350
366
adjustIfTableNotNeedLock ( ) {
351
- if ( this . isOriginLock ( ) && this . tableInc . props . dataSource . length ) {
352
- const configWidths = this . tableInc . flatChildren
367
+ if ( this . isOriginLock ( ) ) {
368
+ const widthObj = this . tableInc . flatChildren
353
369
. map ( ( item , index ) => {
354
- const row = this . getCellNode ( 0 , index ) ;
355
- return ( row && row . clientWidth ) || 0 ;
370
+ const cell = this . getCellNode ( 0 , index ) || { } ;
371
+ const headerCell =
372
+ this . getHeaderCellNode ( 0 , index ) || { } ;
373
+
374
+ return {
375
+ cellWidths : cell . clientWidth || 0 ,
376
+ headerWidths : headerCell . clientWidth || 0 ,
377
+ } ;
356
378
} )
357
- . reduce ( ( a , b ) => a + b , 0 ) ;
379
+ . reduce (
380
+ ( a , b ) => {
381
+ return {
382
+ cellWidths : a . cellWidths + b . cellWidths ,
383
+ headerWidths : a . headerWidths + b . headerWidths ,
384
+ } ;
385
+ } ,
386
+ {
387
+ cellWidths : 0 ,
388
+ headerWidths : 0 ,
389
+ }
390
+ ) ;
358
391
359
392
const node = findDOMNode ( this ) ;
360
393
const width = node . clientWidth ;
361
- const lockLeftLen = this . lockLeftChildren . length ;
362
- const lockRightLen = this . lockRightChildren . length ;
394
+
395
+ // if the table doesn't exist, there is no need to adjust
396
+ if ( width === 0 ) {
397
+ return true ;
398
+ }
399
+
400
+ const configWidths =
401
+ widthObj . cellWidths || widthObj . headerWidths ;
363
402
364
403
if ( configWidths <= width && configWidths > 0 ) {
365
- if ( lockLeftLen ) {
366
- this . _notNeedAdjustLockLeft = true ;
367
- }
368
- if ( lockRightLen ) {
369
- this . _notNeedAdjustLockRight = true ;
370
- }
371
- if ( lockRightLen || lockLeftLen ) {
372
- this . forceUpdate ( ) ;
373
- return true ;
374
- }
404
+ this . removeLockTable ( ) ;
375
405
} else if (
376
406
this . _notNeedAdjustLockLeft ||
377
407
this . _notNeedAdjustLockRight
0 commit comments