Skip to content

Commit

Permalink
fix: sort items by index in case they end in the same position (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
karolzeluk authored Feb 2, 2024
1 parent c2886b2 commit 1a5a95c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/virtual-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,13 @@ export class Virtualizer<

return furthestMeasurements.size === this.options.lanes
? Array.from(furthestMeasurements.values()).sort(
(a, b) => a.end - b.end,
(a, b) => {
if (a.end === b.end) {
return a.index - b.index;
}

return a.end - b.end;
},
)[0]
: undefined
}
Expand Down

0 comments on commit 1a5a95c

Please sign in to comment.