Fix crash when dragging board card with desynced group state

Replace thrown error with graceful handling when a record's ID is not
found in its initial record group's ID list during drag-and-drop. This
state desync can occur during multi-drag operations or rapid navigation.
Instead of crashing, the move now proceeds by skipping the removal step
(record wasn't in the list anyway) and still completing the drop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sonarly Claude Code
2026-02-20 01:02:19 +00:00
co-authored by Claude Opus 4.6
parent 783e57f5d8
commit d0fbd46a19
@@ -96,27 +96,23 @@ export const useUpdateDroppedRecordOnBoard = () => {
recordIndexRecordIdsByGroupCallbackFamilyState(targetRecordGroupId),
);
if (positionOfDroppedRecordInInitialRecordIds === -1) {
throw new Error(
`Cannot find record id in initial record group ids on drop, this should not happen`,
);
}
if (positionOfDroppedRecordInInitialRecordIds !== -1) {
const newInitialGroupRecordIds =
currentRecordIdsInInitialRecordGroup.toSpliced(
positionOfDroppedRecordInInitialRecordIds,
1,
);
const newInitialGroupRecordIds =
currentRecordIdsInInitialRecordGroup.toSpliced(
positionOfDroppedRecordInInitialRecordIds,
1,
);
if (movingInsideSameRecordGroup) {
currentRecordIdsInTargetRecordGroup = newInitialGroupRecordIds;
} else {
set(
recordIndexRecordIdsByGroupCallbackFamilyState(
initialRecordGroupId,
),
newInitialGroupRecordIds,
);
if (movingInsideSameRecordGroup) {
currentRecordIdsInTargetRecordGroup = newInitialGroupRecordIds;
} else {
set(
recordIndexRecordIdsByGroupCallbackFamilyState(
initialRecordGroupId,
),
newInitialGroupRecordIds,
);
}
}
const targetGroupRecordsWithIds = extractRecordPositions(