File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1046,7 +1046,7 @@ export class Virtualizer<
1046
1046
} else {
1047
1047
const endByLane = Array < number | null > ( this . options . lanes ) . fill ( null )
1048
1048
let endIndex = measurements . length - 1
1049
- while ( endIndex > 0 && endByLane . some ( ( val ) => val === null ) ) {
1049
+ while ( endIndex >= 0 && endByLane . some ( ( val ) => val === null ) ) {
1050
1050
const item = measurements [ endIndex ] !
1051
1051
if ( endByLane [ item . lane ] === null ) {
1052
1052
endByLane [ item . lane ] = item . end
@@ -1162,7 +1162,7 @@ function calculateRange({
1162
1162
// Expand backward until we include all lanes' visible items
1163
1163
// closer to the top
1164
1164
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 ) ) {
1166
1166
const item = measurements [ startIndex ] !
1167
1167
startPerLane [ item . lane ] = item . start
1168
1168
startIndex --
Original file line number Diff line number Diff line change @@ -16,3 +16,16 @@ test('should return empty items for empty scroll element', () => {
16
16
} )
17
17
expect ( virtualizer . getVirtualItems ( ) ) . toEqual ( [ ] )
18
18
} )
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