fix: clear card selection on delete to prevent double-deletion error#2921
Open
cqnykamp wants to merge 1 commit into
Open
fix: clear card selection on delete to prevent double-deletion error#2921cqnykamp wants to merge 1 commit into
cqnykamp wants to merge 1 commit into
Conversation
…eletion error After confirming a deletion, the card selection was not cleared. During the loader revalidation window, the deleted item was still visible and selected, allowing the user to trigger a second deletion of the same item. Since the item was already soft-deleted in the database, the API threw a "not found" error, causing the error boundary to render. Fix: clear the card selection when the delete modal opens in both CompoundActivityEditor and Activities so the "Move to trash" button becomes disabled immediately, preventing re-triggering of the deletion. Also adds e2e tests for deleting documents from within a problem set (single, sequential, and full deletion scenarios) to catch regressions. Fixes #2673 https://claude.ai/code/session_01Dr269QvNtnGAywEw3Qx36z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2673 — "Deleting multiple documents from within a problem set causes error"
Root Cause
After the user confirms a deletion, the card selection was not immediately cleared. During the loader revalidation window (between the API committing the deletion and the updated list rendering), the deleted item was still visible and still selected — with the "Move to trash" button still enabled. If the user clicked "Move to trash" again in this window, the app would try to delete an already-soft-deleted item. The API's
findUniqueOrThrow(filtered byisDeletedOn: null) would throw a P2025 "not found" error, whichgenericActionre-threw, causing the error boundary to render.Fix
In both
CompoundActivityEditorandActivities, callcardSelections.clear()when the delete confirmation modal opens. This immediately disables the "Move to trash" button (which requirescount === 1), preventing re-triggering of deletion before the list revalidates.apps/app/src/views/CompoundActivityEditor.tsx— primary fix for the problem set editor (the reported scenario)apps/app/src/paths/Activities.tsx— same fix applied to the folder/activities view, which had the identical patternTests Added
New e2e test file
deleteFromCompoundActivity.cy.tscovering:https://claude.ai/code/session_01Dr269QvNtnGAywEw3Qx36z
Generated by Claude Code