Skip to content

fix: improve global forms modal behavior#945

Merged
smarcet merged 1 commit into
masterfrom
fix/global-forms-form-close-update-list
May 18, 2026
Merged

fix: improve global forms modal behavior#945
smarcet merged 1 commit into
masterfrom
fix/global-forms-form-close-update-list

Conversation

@priscila-moneo
Copy link
Copy Markdown

@priscila-moneo priscila-moneo commented May 18, 2026

ref: https://app.clickup.com/t/86b8tct5y?comment=90140205951559

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed form template saving to properly persist materials and meta fields with correct defaults
    • Prevented duplicate form submissions by disabling submit button during save operation
    • Dialog remains open during save and prevents unintended closure via keyboard until submission completes
    • Success messages now display correctly after creating or updating form templates

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@priscila-moneo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 52 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c6ea6b23-14d4-4ec5-98ef-47dceb4855b1

📥 Commits

Reviewing files that changed from the base of the PR and between ee79623 and 245192f.

📒 Files selected for processing (3)
  • src/actions/form-template-actions.js
  • src/pages/sponsors-global/form-templates/form-template-list-page.js
  • src/pages/sponsors-global/form-templates/form-template-popup.js
📝 Walkthrough

Walkthrough

The PR refactors the form template save flow to properly manage list refresh state and prevent duplicate submissions. The action thunk now reads pagination context to refresh the list with correct parameters, and the dialog adds save-state gating to prevent concurrent submissions while controlling closing behavior.

Changes

Form Template Save Flow Improvements

Layer / File(s) Summary
Action thunk refactoring: state context and list refresh
src/actions/form-template-actions.js
saveFormTemplate now accepts getState to read currentFormTemplateListState pagination/filter/sort context, extracts material and meta-field defaults from the entity, and refreshes the list after successful saves. Both update and create flows chain Promise.all(...) through then(refreshList).then(showSuccessMessage) with finally cleanup. The history import is removed; navigation via history.push is eliminated.
Dialog save state management: prevent duplicate submissions
src/pages/sponsors-global/form-templates/form-template-popup.js
Added isSaving state and closePopup() helper to FormTemplateDialog. The submit handler wraps onSave(finalValues) in Promise.resolve, closes on success, keeps the dialog open on error, and always clears isSaving in finally. Close button, Escape-key closing, and submit button are all disabled while saving.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • fntechgit/summit-admin#824: Implements the same patterns for preventing duplicate submissions with isSaving state gating, keeping modals open on save failure, and refactoring promise chains to use then/finally instead of .catch swallowing.

Suggested reviewers

  • caseylocker
  • smarcet
  • santipalenque

Poem

🐰 A dialog saves with grace and care,
No duplicates shall sneak in there—
The action refreshes, state flows true,
A promise chain made clean and new! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: improve global forms modal behavior' is related to the changes but overly broad. It mentions modal behavior improvements, which is only partially addressed by the form-template-popup.js changes, while missing the primary refactoring of saveFormTemplate action logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/global-forms-form-close-update-list

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

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/sponsors-global/form-templates/form-template-popup.js`:
- Around line 74-86: The catch block for Promise.resolve(onSave(finalValues))
silently swallows errors; update the catch to surface and record failures by
logging the error and/or forwarding it to the existing error handler so
developers and users see save failures (e.g., call console.error or the
authErrorHandler with the caught error), and optionally show a user-facing
message before leaving the finally that calls setIsSaving(false); keep
references to isSaving/setIsSaving/onSave/closePopup so you modify the promise
chain around onSave(finalValues) and ensure closePopup only runs on success.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7d4168d1-1521-4511-a8ce-ac6bd79c8b12

📥 Commits

Reviewing files that changed from the base of the PR and between 45ffe84 and ee79623.

📒 Files selected for processing (2)
  • src/actions/form-template-actions.js
  • src/pages/sponsors-global/form-templates/form-template-popup.js

Comment on lines +74 to +86
if (isSaving) return;

setIsSaving(true);
Promise.resolve(onSave(finalValues))
.then(() => {
closePopup();
})
.catch(() => {
// keep dialog open on save error to preserve user input
})
.finally(() => {
setIsSaving(false);
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Silent error swallowing hides save failures from users and developers.

The empty .catch(() => {}) suppresses all errors without logging or user notification. When a save fails, users won't know what happened or if a partial save occurred, and debugging becomes difficult without any error traces.

Proposed fix to add error logging
       .catch(() => {
-        // keep dialog open on save error to preserve user input
+        // keep dialog open on save error to preserve user input
+        // errors are displayed via authErrorHandler in the action
+        console.error("Form template save failed");
       })

Alternatively, if onSave already displays error messages via authErrorHandler, consider documenting that explicitly in the comment so future maintainers know errors are handled upstream.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (isSaving) return;
setIsSaving(true);
Promise.resolve(onSave(finalValues))
.then(() => {
closePopup();
})
.catch(() => {
// keep dialog open on save error to preserve user input
})
.finally(() => {
setIsSaving(false);
});
if (isSaving) return;
setIsSaving(true);
Promise.resolve(onSave(finalValues))
.then(() => {
closePopup();
})
.catch(() => {
// keep dialog open on save error to preserve user input
// errors are displayed via authErrorHandler in the action
console.error("Form template save failed");
})
.finally(() => {
setIsSaving(false);
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/sponsors-global/form-templates/form-template-popup.js` around lines
74 - 86, The catch block for Promise.resolve(onSave(finalValues)) silently
swallows errors; update the catch to surface and record failures by logging the
error and/or forwarding it to the existing error handler so developers and users
see save failures (e.g., call console.error or the authErrorHandler with the
caught error), and optionally show a user-facing message before leaving the
finally that calls setIsSaving(false); keep references to
isSaving/setIsSaving/onSave/closePopup so you modify the promise chain around
onSave(finalValues) and ensure closePopup only runs on success.

Signed-off-by: Priscila Moneo <priscila_moneo@hotmail.com.ar>
@priscila-moneo priscila-moneo force-pushed the fix/global-forms-form-close-update-list branch from ee79623 to 245192f Compare May 18, 2026 18:09
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

Copy link
Copy Markdown

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

LGTM

@smarcet smarcet merged commit 7f5ff69 into master May 18, 2026
9 checks passed
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.

3 participants