fix(reorder-group): dragging reorder item to bottom no longer gives out of bounds index (#23797)

resolves #23796
This commit is contained in:
Toby Smith
2021-08-23 14:38:27 +01:00
committed by GitHub
parent 864212b0f2
commit 02409f2abf

View File

@@ -245,17 +245,16 @@ export class ReorderGroup implements ComponentInterface {
private itemIndexForTop(deltaY: number): number {
const heights = this.cachedHeights;
let i = 0;
// TODO: since heights is a sorted array of integers, we can do
// speed up the search using binary search. Remember that linear-search is still
// faster than binary-search for small arrays (<64) due CPU branch misprediction.
for (i = 0; i < heights.length; i++) {
for (let i = 0; i < heights.length; i++) {
if (heights[i] > deltaY) {
break;
return i;
}
}
return i;
return heights.length - 1;
}
/********* DOM WRITE ********* */