From d0fbd46a19c44f175db4117216abcc69e9bbedc2 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Fri, 20 Feb 2026 01:02:19 +0000 Subject: [PATCH] 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 --- .../hooks/useUpdateDroppedRecordOnBoard.ts | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/twenty-front/src/modules/object-record/record-drag/hooks/useUpdateDroppedRecordOnBoard.ts b/packages/twenty-front/src/modules/object-record/record-drag/hooks/useUpdateDroppedRecordOnBoard.ts index 29e9e9132d8..3deba7976ce 100644 --- a/packages/twenty-front/src/modules/object-record/record-drag/hooks/useUpdateDroppedRecordOnBoard.ts +++ b/packages/twenty-front/src/modules/object-record/record-drag/hooks/useUpdateDroppedRecordOnBoard.ts @@ -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(