@@ -2906,18 +2906,26 @@ describe("thread entry with the real virtualizer", () => {
29062906 // jsdom supplies no layout. Give the real virtualizer a 600px viewport
29072907 // and 180px message rows, twice its 90px estimate.
29082908 let lastRowHeight = 180 ;
2909+ const rowHeights = new Map < number , number > ( ) ;
29092910 let pendingScrollHeight : number | undefined ;
29102911 let pendingViewportHeight : number | undefined ;
29112912 const rectSpy = vi
29122913 . spyOn ( HTMLElement . prototype , "getBoundingClientRect" )
29132914 . mockImplementation ( function ( this : HTMLElement ) {
2915+ const rowIndex = Number (
2916+ this . querySelector ( "[data-message-id]" )
2917+ ?. getAttribute ( "data-message-id" )
2918+ ?. match ( / ^ m e s s a g e - ( \d + ) $ / ) ?. [ 1 ] ,
2919+ ) ;
29142920 const height = this . classList . contains ( "messages-timeline-scroll" )
29152921 ? 600
29162922 : this . firstElementChild ?. classList . contains ( "messages-timeline-row-frame" )
2917- ? this . textContent ?. includes ( "Message 39" ) ||
2918- this . textContent ?. includes ( "Thread B message 39" )
2919- ? lastRowHeight
2920- : 180
2923+ ? rowHeights . has ( rowIndex )
2924+ ? rowHeights . get ( rowIndex ) !
2925+ : this . textContent ?. includes ( "Message 39" ) ||
2926+ this . textContent ?. includes ( "Thread B message 39" )
2927+ ? lastRowHeight
2928+ : 180
29212929 : this . style . height . endsWith ( "px" )
29222930 ? Number . parseFloat ( this . style . height )
29232931 : 0 ;
@@ -3130,6 +3138,7 @@ describe("thread entry with the real virtualizer", () => {
31303138 cancelTimelineProgrammaticScroll ( props . listRef . current ) ;
31313139 setFollow ( false ) ;
31323140 } ,
3141+ ( ) => props . listRef . current ?. getState ( ) . scroll ,
31333142 ) ,
31343143 [ ] ,
31353144 ) ;
@@ -3162,6 +3171,33 @@ describe("thread entry with the real virtualizer", () => {
31623171 readingViewport . scrollHeight - readingViewport . clientHeight - readingViewport . scrollTop ,
31633172 ) ,
31643173 ) . toBeLessThanOrEqual ( 1 ) ;
3174+ if ( geometryChange === "none" ) {
3175+ // Native visible-position corrections must not be mistaken for navigation.
3176+ const aboveRow = Math . min (
3177+ ...Array . from ( readingViewport . querySelectorAll ( "[data-message-id]" ) )
3178+ . map ( ( row ) =>
3179+ Number ( row . getAttribute ( "data-message-id" ) ?. match ( / ^ m e s s a g e - ( \d + ) $ / ) ?. [ 1 ] ) ,
3180+ )
3181+ . filter ( Number . isFinite ) ,
3182+ ) ;
3183+ expect ( aboveRow ) . toBeLessThan ( 39 ) ;
3184+ for ( const tailGrowth of [ 60 , 0 , 240 ] ) {
3185+ rowHeights . set ( aboveRow , 60 ) ;
3186+ lastRowHeight = 180 + tailGrowth ;
3187+ await flushLayout ( ) ;
3188+ expect ( unsignaledNavigation ) . not . toHaveBeenCalled ( ) ;
3189+ expect (
3190+ Math . abs (
3191+ readingViewport . scrollHeight -
3192+ readingViewport . clientHeight -
3193+ readingViewport . scrollTop ,
3194+ ) ,
3195+ ) . toBeLessThanOrEqual ( 1 ) ;
3196+ rowHeights . clear ( ) ;
3197+ lastRowHeight = 180 ;
3198+ await flushLayout ( ) ;
3199+ }
3200+ }
31653201 await act ( async ( ) => {
31663202 // A shrink and external navigation can coalesce into one scroll event.
31673203 // The browser first clamps the old offset, then the reader moves farther up.
0 commit comments