File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -497,8 +497,11 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
497
497
} ;
498
498
499
499
const triggerOnScroll = ( ) => {
500
- if ( scrollBodyRef . current ) {
500
+ if ( horizonScroll && scrollBodyRef . current ) {
501
501
onScroll ( { currentTarget : scrollBodyRef . current } as React . UIEvent < HTMLDivElement > ) ;
502
+ } else {
503
+ setPingedLeft ( false ) ;
504
+ setPingedRight ( false ) ;
502
505
}
503
506
} ;
504
507
@@ -510,20 +513,17 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
510
513
} ;
511
514
512
515
// Sync scroll bar when init or `horizonScroll`, `data` and `columns.length` changed
513
- React . useEffect ( ( ) => triggerOnScroll , [ ] ) ;
516
+ const mounted = React . useRef ( false ) ;
514
517
React . useEffect ( ( ) => {
515
- if ( horizonScroll ) {
518
+ // onFullTableResize will be trigger once when ResizeObserver is mounted
519
+ // This will reduce one duplicated triggerOnScroll time
520
+ if ( mounted . current ) {
516
521
triggerOnScroll ( ) ;
517
522
}
518
- } , [ data , columns . length ] ) ;
523
+ } , [ horizonScroll , data , columns . length ] ) ;
519
524
React . useEffect ( ( ) => {
520
- if ( horizonScroll ) {
521
- triggerOnScroll ( ) ;
522
- } else {
523
- setPingedLeft ( false ) ;
524
- setPingedRight ( false ) ;
525
- }
526
- } , [ horizonScroll ] ) ;
525
+ mounted . current = true ;
526
+ } , [ ] ) ;
527
527
528
528
// ===================== Effects ======================
529
529
const [ scrollbarSize , setScrollbarSize ] = React . useState ( 0 ) ;
You can’t perform that action at this time.
0 commit comments