fix(event-types): skip save when form has no changes#29674
fix(event-types): skip save when form has no changes#29674sreecharan-desu wants to merge 3 commits into
Conversation
Fixes calcom#13112 Save was still reachable via submit paths even with no edits. Bail out of handleSubmit when the form is not dirty (Save button already disabled in UI).
|
Welcome to Cal.diy, @sreecharan-desu! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 `@packages/platform/atoms/event-types/hooks/useEventTypeForm.ts`:
- Around line 287-290: The handleSubmit path in useEventTypeForm currently
returns nothing when the form is clean, which lets EventTypePlatformWrapper
treat a skipped submit as a successful save. Update handleSubmit to return an
explicit status/result indicating whether a mutation actually ran, and make the
submit caller in EventTypePlatformWrapper await and check that result before
firing customCallbacks.onSuccess. Use the handleSubmit and
customCallbacks.onSuccess symbols to keep the submit flow from reporting success
on no-op submissions.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9317890c-7a1d-4afb-aa42-02e39e0badf6
📒 Files selected for processing (1)
packages/platform/atoms/event-types/hooks/useEventTypeForm.ts
Return a boolean from handleSubmit so programmatic submits on a clean form do not fire success callbacks.
There was a problem hiding this comment.
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 `@packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx`:
- Around line 186-191: The success callback is being triggered too early in
EventTypePlatformWrapper because handleSubmit only returns after starting
updateMutation.mutate(data), not after the mutation finishes. Update the
submission flow around form.handleSubmit, handleSubmit, and updateMutation so
onSuccess is fired only from the mutation completion path (for example via
updateMutation.onSuccess/callbacksRef.current) and remove the immediate success
check after await handleSubmit(data) to avoid double-firing and false 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 00120829-9f13-4f56-b7e3-f04fb7b264db
📒 Files selected for processing (2)
packages/platform/atoms/event-types/hooks/useEventTypeForm.tspackages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/platform/atoms/event-types/hooks/useEventTypeForm.ts
Remove the premature customCallbacks.onSuccess call from the programmatic submit path so success is only reported from updateMutation.onSuccess after the request finishes.
|
This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active. |
Fixes #13112
Save was already disabled when the form isn't dirty, but
handleSubmitcould still fire (programmatic submit) and hit the API anyway. Early return when!isFormDirty.Checked in the event type editor: no edits → Save stays disabled; change title → Save enables and persists.