Skip to content

fix: [DHIS2-21741] Failed event deletion is not rolled back in the UI - #4636

Merged
henrikmv merged 2 commits into
masterfrom
hv/fix/DHIS2-21741_roll-back-event-if-deletion-fails
Jul 2, 2026
Merged

fix: [DHIS2-21741] Failed event deletion is not rolled back in the UI#4636
henrikmv merged 2 commits into
masterfrom
hv/fix/DHIS2-21741_roll-back-event-if-deletion-fails

Conversation

@henrikmv

@henrikmv henrikmv commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

DHIS2-21741

Simplifies the delete-event rollback mechanism in DeleteActionModal by replacing the React Query cache lookup with a direct prop.

The delete removes the event from Redux, but the rollback previously read the event data from a separate React Query cache. That cache can be stale, and newly created in-session events are not always present there, which meant rollback could be skipped on delete failure.

Previously, on mutation start the component reconstructed a query key from teiId, programId, and enrollmentId, then dug into the cached enrollment data to find the event for rollback. Now, the already-rendered eventDetails object from EventRow is passed in as a prop and used directly:

- queryClient.getQueryData(key)
-   ?.enrollments
-   ?.flatMap(...)
-   ?.find(e => e.event === eventId)
+ const eventToRollbackOnFail = eventDetails;

This ensures the event is always available for rollback and restored on failure, including newly created in-session events.

This also removes the useQueryClient hook, the ReactQueryAppNamespace import, and three individual ID props in favor of a single typed eventDetails: ApiEnrollmentEvent prop.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@henrikmv
henrikmv marked this pull request as ready for review July 1, 2026 15:26
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

@simonadomnisoru simonadomnisoru left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@linadhis2

Copy link
Copy Markdown

LGTM from QA perspective.

@henrikmv
henrikmv merged commit 0d64927 into master Jul 2, 2026
59 of 61 checks passed
@henrikmv
henrikmv deleted the hv/fix/DHIS2-21741_roll-back-event-if-deletion-fails branch July 2, 2026 15:26
dhis2-bot added a commit that referenced this pull request Jul 2, 2026
## [106.6.2](v106.6.1...v106.6.2) (2026-07-02)

### Bug Fixes

* [DHIS2-21741] Failed event deletion is not rolled back in the UI ([#4636](#4636)) ([0d64927](0d64927))
@dhis2-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 106.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants