@@ -320,7 +320,7 @@ describe('getScrollActionForRow', () => {
320320 expect ( action . scrollTop ) . toBeCloseTo ( expectedScrollTop , 0 )
321321 } )
322322
323- it ( 'returns a scrollTop action when the accumulated delta would exceed largeScrollPx threshold' , ( ) => {
323+ it ( 'returns a local scroll action event if the accumulated delta would exceed largeScrollPx threshold' , ( ) => {
324324 const scale = createScale ( {
325325 clientHeight : 1_000 ,
326326 headerHeight : 50 ,
@@ -334,10 +334,7 @@ describe('getScrollActionForRow', () => {
334334 // should add a small delta (2_317), but the accumulated delta (18_817) exceeds largeScrollPx, so: scrollTop is returned to synchronize properly
335335 // TODO(SL): directly set scrollTopAnchor instead of virtualScrollBase
336336 const action = getScrollActionForRow ( { scale, rowIndex, scrollTopAnchor : scale . fromVirtual ( virtualScrollBase ) , localOffset } )
337- if ( ! action || ! ( 'scrollTop' in action ) ) {
338- throw new Error ( 'Expected a scrollTop action' )
339- }
340- expect ( action . scrollTop ) . toBeCloseTo ( 5_284 , 0 )
337+ expect ( action ?. type ) . toBe ( 'LOCAL_SCROLL' )
341338 } )
342339
343340 it . each ( [
@@ -554,15 +551,16 @@ describe('scrollReducer', () => {
554551 expect ( newState . localOffset ) . toBe ( 0 )
555552 } )
556553
557- it ( 'scrolls globally when the accumulated localOffset would be too large' , ( ) => {
554+ it ( 'scrolls locally even if the accumulated localOffset is large' , ( ) => {
555+ const largeLocalOffset = 16_499 // below the largeScrollPx threshold (500 * 33 = 16,500)
558556 const stateWithLargeLocalOffset : ScrollState = {
559557 ...initialState ,
560- localOffset : 16_499 , // below the largeScrollPx threshold (500 * 33 = 16,500)
558+ localOffset : largeLocalOffset ,
561559 }
562560 const newState = scrollReducer ( stateWithLargeLocalOffset , { type : 'ON_SCROLL' , scrollTop : nearScrollTop } )
563561 expect ( newState . scrollTop ) . toBe ( nearScrollTop )
564- expect ( newState . scrollTopAnchor ) . toBe ( nearScrollTop )
565- expect ( newState . localOffset ) . toBe ( 0 )
562+ expect ( newState . scrollTopAnchor ) . toBe ( initialScrollTop ) // unchanged
563+ expect ( newState . localOffset ) . toBe ( largeLocalOffset + ( nearScrollTop - initialScrollTop ) ) // accumulated local offset is above the threshold, but we still scroll locally
566564 } )
567565
568566 it ( 'scrolls globally, and scrollTopAnchor is clamped, when scrollTop is non-positive' , ( ) => {
0 commit comments