Skip to content

fix: clear card selection on delete to prevent double-deletion error#2921

Open
cqnykamp wants to merge 1 commit into
mainfrom
claude/modest-franklin-iGhy5
Open

fix: clear card selection on delete to prevent double-deletion error#2921
cqnykamp wants to merge 1 commit into
mainfrom
claude/modest-franklin-iGhy5

Conversation

@cqnykamp

Copy link
Copy Markdown
Contributor

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 by isDeletedOn: null) would throw a P2025 "not found" error, which genericAction re-threw, causing the error boundary to render.

Fix

In both CompoundActivityEditor and Activities, call cardSelections.clear() when the delete confirmation modal opens. This immediately disables the "Move to trash" button (which requires count === 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 pattern

Tests Added

New e2e test file deleteFromCompoundActivity.cy.ts covering:

  1. Deleting a single document from a problem set
  2. Deleting multiple documents sequentially from the same problem set (the main bug scenario)
  3. Deleting all documents from a problem set

https://claude.ai/code/session_01Dr269QvNtnGAywEw3Qx36z


Generated by Claude Code

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting multiple documents from within a problem set causes error

2 participants