fix: always re-generate index of defined moved elements (#8040)

This commit is contained in:
Marcel Mraz 2024-05-20 22:23:42 +01:00 committed by GitHub
parent 2f9526da24
commit eddbe55f50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 151 additions and 125 deletions

View file

@ -133,27 +133,11 @@ const getMovedIndicesGroups = (
let i = 0;
while (i < elements.length) {
if (
movedElements.has(elements[i].id) &&
!isValidFractionalIndex(
elements[i]?.index,
elements[i - 1]?.index,
elements[i + 1]?.index,
)
) {
if (movedElements.has(elements[i].id)) {
const indicesGroup = [i - 1, i]; // push the lower bound index as the first item
while (++i < elements.length) {
if (
!(
movedElements.has(elements[i].id) &&
!isValidFractionalIndex(
elements[i]?.index,
elements[i - 1]?.index,
elements[i + 1]?.index,
)
)
) {
if (!movedElements.has(elements[i].id)) {
break;
}