Skip to content

Commit 02409f2

Browse files
authoredAug 23, 2021
fix(reorder-group): dragging reorder item to bottom no longer gives out of bounds index (#23797)
resolves #23796
1 parent 864212b commit 02409f2

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 

‎core/src/components/reorder-group/reorder-group.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,16 @@ export class ReorderGroup implements ComponentInterface {
245245

246246
private itemIndexForTop(deltaY: number): number {
247247
const heights = this.cachedHeights;
248-
let i = 0;
249248

250249
// TODO: since heights is a sorted array of integers, we can do
251250
// speed up the search using binary search. Remember that linear-search is still
252251
// faster than binary-search for small arrays (<64) due CPU branch misprediction.
253-
for (i = 0; i < heights.length; i++) {
252+
for (let i = 0; i < heights.length; i++) {
254253
if (heights[i] > deltaY) {
255-
break;
254+
return i;
256255
}
257256
}
258-
return i;
257+
return heights.length - 1;
259258
}
260259

261260
/********* DOM WRITE ********* */

0 commit comments

Comments
 (0)
Please sign in to comment.