Skip to content

Commit 51656d9

Browse files
authored
fix(core): handle case when item count is less than or equal to lanes (#964)
1 parent f650006 commit 51656d9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.changeset/tall-masks-call.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/virtual-core': patch
3+
---
4+
5+
fix(core): handle case when item count is less than or equal to lanes

packages/virtual-core/src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,14 @@ function calculateRange({
11231123
const lastIndex = measurements.length - 1
11241124
const getOffset = (index: number) => measurements[index]!.start
11251125

1126+
// handle case when item count is less than or equal to lanes
1127+
if (measurements.length <= lanes) {
1128+
return {
1129+
startIndex: 0,
1130+
endIndex: lastIndex,
1131+
}
1132+
}
1133+
11261134
let startIndex = findNearestBinarySearch(
11271135
0,
11281136
lastIndex,

0 commit comments

Comments
 (0)