Skip to content

fix: edit cart unsaved changes fix#866

Open
priscila-moneo wants to merge 1 commit intomasterfrom
fix/edit-cart-form-unsaved-changes-fix
Open

fix: edit cart unsaved changes fix#866
priscila-moneo wants to merge 1 commit intomasterfrom
fix/edit-cart-form-unsaved-changes-fix

Conversation

@priscila-moneo
Copy link
Copy Markdown

@priscila-moneo priscila-moneo commented Apr 9, 2026

ref: https://app.clickup.com/t/86b91h13q

Summary by CodeRabbit

  • New Features

    • Added confirmation dialog that prompts users to discard unsaved changes when canceling a form with pending edits.
  • Tests

    • Added test coverage for the unsaved changes confirmation flow.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 74924ac6-0561-4c41-aeeb-85f0847596be

📥 Commits

Reviewing files that changed from the base of the PR and between 033cf84 and ff0d4d2.

📒 Files selected for processing (3)
  • src/i18n/en.json
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/__tests__/edit-cart-form.test.js
  • src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/index.js

📝 Walkthrough

Walkthrough

Added an unsaved changes confirmation warning to the sponsor cart edit form. When users cancel with unsaved changes, a dialog prompts them to confirm discarding modifications before proceeding.

Changes

Cohort / File(s) Summary
Translation
src/i18n/en.json
Added English translation string for unsaved_changes_warning prompt in cart edit form context.
Edit Form Implementation
src/pages/sponsors/.../edit-form/index.js
Refactored handleCancel to async flow; now checks form dirty state and shows confirmation dialog via showConfirmDialog before invoking callback.
Form Tests
src/pages/sponsors/.../edit-form/__tests__/edit-cart-form.test.js
Added Jest mocks for showConfirmDialog and NotesModal; introduced new test cases for cancel-flow with unsaved changes, validating confirmation dialog invocation and conditional callback execution.

Sequence Diagram

sequenceDiagram
    actor User
    participant EditForm as Edit Form Component
    participant Dialog as Confirm Dialog
    participant Parent as Parent Handler

    User->>EditForm: Click Cancel
    activate EditForm
    EditForm->>EditForm: Check if form.dirty
    alt Form has unsaved changes
        EditForm->>Dialog: Show confirmation dialog
        activate Dialog
        Dialog->>User: "Discard changes?"
        User->>Dialog: Confirm (Yes/No)
        Dialog-->>EditForm: Return user choice
        deactivate Dialog
        alt User confirms discard
            EditForm->>Parent: Call onCancel()
        else User declines
            EditForm-->>User: Return (no action)
        end
    else No unsaved changes
        EditForm->>Parent: Call onCancel()
    end
    deactivate EditForm
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • smarcet
  • martinquiroga-exo
  • caseylocker

Poem

🐰 Hop hop, changes saved at last,
A warning guard to make them last,
Discard or stay, the choice is thine,
Unsaved changes? Now they shine!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: edit cart unsaved changes fix' is related to the changeset, which adds unsaved changes detection and confirmation dialogs to the edit cart form, but it's somewhat redundant and unclear due to the repetition of 'fix'.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/edit-cart-form-unsaved-changes-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@santipalenque santipalenque left a comment

Choose a reason for hiding this comment

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

LGTM

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.

2 participants