@@ -22,6 +22,7 @@ import type { ExtraRenderInfo, GetKey, RenderFunc, SharedConfig } from './interf
22
22
import type { ScrollBarDirectionType , ScrollBarRef } from './ScrollBar' ;
23
23
import ScrollBar from './ScrollBar' ;
24
24
import { getSpinSize } from './utils/scrollbarUtil' ;
25
+ import { debounce } from './utils/debounce' ;
25
26
26
27
const EMPTY_DATA = [ ] ;
27
28
@@ -271,10 +272,15 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
271
272
rangeRef . current . start = start ;
272
273
rangeRef . current . end = end ;
273
274
275
+ const isScrollingRef = useRef ( false ) ;
274
276
// When scroll up, first visible item get real height may not same as `itemHeight`,
275
277
// Which will make scroll jump.
276
278
// Let's sync scroll top to avoid jump
277
279
React . useLayoutEffect ( ( ) => {
280
+ // When the `scrollHeight` change is not caused by scrolling,
281
+ // end the function execution avoiding table jitter caused by changes in the first row
282
+ if ( ! isScrollingRef . current ) return ;
283
+
278
284
const changedRecord = heights . getRecord ( ) ;
279
285
if ( changedRecord . size === 1 ) {
280
286
const recordKey = Array . from ( changedRecord ) [ 0 ] ;
@@ -377,6 +383,9 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
377
383
}
378
384
}
379
385
386
+ const toggleScrollStatus = React . useCallback ( debounce ( ( ) => {
387
+ isScrollingRef . current = false ;
388
+ } , 100 ) , [ ] ) ;
380
389
// When data size reduce. It may trigger native scroll event back to fit scroll position
381
390
function onFallbackScroll ( e : React . UIEvent < HTMLDivElement > ) {
382
391
const { scrollTop : newScrollTop } = e . currentTarget ;
@@ -387,6 +396,10 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
387
396
// Trigger origin onScroll
388
397
onScroll ?.( e ) ;
389
398
triggerScroll ( ) ;
399
+ // Set the scroll status to `true`
400
+ isScrollingRef . current = true ;
401
+ // Set the scroll status to `false` after scrolling ends
402
+ toggleScrollStatus ( ) ;
390
403
}
391
404
392
405
const keepInHorizontalRange = ( nextOffsetLeft : number ) => {
0 commit comments