Skip to content

Commit

Permalink
fix: edge case with a single group
Browse files Browse the repository at this point in the history
Fixes #886
  • Loading branch information
petyosi committed Apr 26, 2023
1 parent f4dd1a5 commit 2e73470
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/sizeSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ export const sizeSystem = u.system(

while (prependedGroupItemsCount < unshiftWith) {
const theGroupIndex = sizes.groupIndices[groupIndex]
const groupItemCount = sizes.groupIndices[groupIndex + 1] - theGroupIndex - 1
const groupItemCount =
sizes.groupIndices.length === groupIndex + 1 ? Infinity : sizes.groupIndices[groupIndex + 1] - theGroupIndex - 1

initialRanges.push({
startIndex: theGroupIndex,
Expand Down
3 changes: 2 additions & 1 deletion src/upwardScrollFixSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export const upwardScrollFixSystem = u.system(
recognizedOffsetItems++
amount += defaultGroupSize

let groupItemCount = groupIndices[groupIndex + 1] - groupIndices[groupIndex] - 1
let groupItemCount =
groupIndices.length === groupIndex + 1 ? Infinity : groupIndices[groupIndex + 1] - groupIndices[groupIndex] - 1

// if the group is larger than the offset, we have an expanded group. remove the group size, and replace with 1 item.
if (recognizedOffsetItems + groupItemCount > offset) {
Expand Down

0 comments on commit 2e73470

Please sign in to comment.