@@ -121,6 +121,9 @@ export interface TableProps<RecordType = unknown>
121
121
122
122
sticky ?: boolean | TableSticky ;
123
123
124
+ // Events
125
+ onScroll ?: React . UIEventHandler < HTMLDivElement > ;
126
+
124
127
// =================================== Internal ===================================
125
128
/**
126
129
* @private Internal usage, may remove by refactor. Should always use `columns` instead.
@@ -204,6 +207,9 @@ function Table<RecordType extends DefaultRecordType>(
204
207
onRow,
205
208
onHeaderRow,
206
209
210
+ // Events
211
+ onScroll,
212
+
207
213
// Internal
208
214
internalHooks,
209
215
transformColumns,
@@ -426,7 +432,7 @@ function Table<RecordType extends DefaultRecordType>(
426
432
}
427
433
}
428
434
429
- const onScroll = useEvent (
435
+ const onInternalScroll = useEvent (
430
436
( { currentTarget, scrollLeft } : { currentTarget : HTMLElement ; scrollLeft ?: number } ) => {
431
437
const isRTL = direction === 'rtl' ;
432
438
const mergedScrollLeft =
@@ -462,9 +468,14 @@ function Table<RecordType extends DefaultRecordType>(
462
468
} ,
463
469
) ;
464
470
471
+ const onBodyScroll = useEvent ( ( e : React . UIEvent < HTMLDivElement > ) => {
472
+ onInternalScroll ( e ) ;
473
+ onScroll ?.( e ) ;
474
+ } ) ;
475
+
465
476
const triggerOnScroll = ( ) => {
466
477
if ( horizonScroll && scrollBodyRef . current ) {
467
- onScroll ( { currentTarget : scrollBodyRef . current } as React . UIEvent < HTMLDivElement > ) ;
478
+ onInternalScroll ( { currentTarget : scrollBodyRef . current } as React . UIEvent < HTMLDivElement > ) ;
468
479
} else {
469
480
setPingedLeft ( false ) ;
470
481
setPingedRight ( false ) ;
@@ -606,7 +617,7 @@ function Table<RecordType extends DefaultRecordType>(
606
617
bodyContent = customizeScrollBody ( mergedData , {
607
618
scrollbarSize,
608
619
ref : scrollBodyRef ,
609
- onScroll,
620
+ onScroll : onInternalScroll ,
610
621
} ) ;
611
622
612
623
headerProps . colWidths = flattenColumns . map ( ( { width } , index ) => {
@@ -631,7 +642,7 @@ function Table<RecordType extends DefaultRecordType>(
631
642
...scrollXStyle ,
632
643
...scrollYStyle ,
633
644
} }
634
- onScroll = { onScroll }
645
+ onScroll = { onBodyScroll }
635
646
ref = { scrollBodyRef }
636
647
className = { classNames ( `${ prefixCls } -body` ) }
637
648
>
@@ -663,7 +674,7 @@ function Table<RecordType extends DefaultRecordType>(
663
674
...columnContext ,
664
675
direction,
665
676
stickyClassName,
666
- onScroll,
677
+ onScroll : onInternalScroll ,
667
678
} ;
668
679
669
680
groupTableNode = (
@@ -700,7 +711,7 @@ function Table<RecordType extends DefaultRecordType>(
700
711
ref = { stickyRef }
701
712
offsetScroll = { offsetScroll }
702
713
scrollBodyRef = { scrollBodyRef }
703
- onScroll = { onScroll }
714
+ onScroll = { onInternalScroll }
704
715
container = { container }
705
716
data = { data }
706
717
/>
@@ -716,7 +727,7 @@ function Table<RecordType extends DefaultRecordType>(
716
727
...scrollYStyle ,
717
728
} }
718
729
className = { classNames ( `${ prefixCls } -content` ) }
719
- onScroll = { onScroll }
730
+ onScroll = { onInternalScroll }
720
731
ref = { scrollBodyRef }
721
732
>
722
733
< TableComponent
0 commit comments