File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1046,7 +1046,7 @@ export class Virtualizer<
10461046 } else {
10471047 const endByLane = Array < number | null > ( this . options . lanes ) . fill ( null )
10481048 let endIndex = measurements . length - 1
1049- while ( endIndex > 0 && endByLane . some ( ( val ) => val === null ) ) {
1049+ while ( endIndex >= 0 && endByLane . some ( ( val ) => val === null ) ) {
10501050 const item = measurements [ endIndex ] !
10511051 if ( endByLane [ item . lane ] === null ) {
10521052 endByLane [ item . lane ] = item . end
@@ -1162,7 +1162,7 @@ function calculateRange({
11621162 // Expand backward until we include all lanes' visible items
11631163 // closer to the top
11641164 const startPerLane = Array ( lanes ) . fill ( scrollOffset + outerSize )
1165- while ( startIndex > 0 && startPerLane . some ( ( pos ) => pos >= scrollOffset ) ) {
1165+ while ( startIndex >= 0 && startPerLane . some ( ( pos ) => pos >= scrollOffset ) ) {
11661166 const item = measurements [ startIndex ] !
11671167 startPerLane [ item . lane ] = item . start
11681168 startIndex --
Original file line number Diff line number Diff line change @@ -16,3 +16,16 @@ test('should return empty items for empty scroll element', () => {
1616 } )
1717 expect ( virtualizer . getVirtualItems ( ) ) . toEqual ( [ ] )
1818} )
19+
20+ test ( 'should return correct total size with one item and multiple lanes' , ( ) => {
21+ const virtualizer = new Virtualizer ( {
22+ count : 1 ,
23+ lanes : 2 ,
24+ estimateSize : ( ) => 50 ,
25+ getScrollElement : ( ) => null ,
26+ scrollToFn : vi . fn ( ) ,
27+ observeElementRect : vi . fn ( ) ,
28+ observeElementOffset : vi . fn ( ) ,
29+ } )
30+ expect ( virtualizer . getTotalSize ( ) ) . toBe ( 50 )
31+ } )
You can’t perform that action at this time.
0 commit comments