Skip to content

fix: disable save button when no real event type changes exist#28690

Open
seffhunnn wants to merge 3 commits intocalcom:mainfrom
seffhunnn:fix-disable-save-button-no-real-changes
Open

fix: disable save button when no real event type changes exist#28690
seffhunnn wants to merge 3 commits intocalcom:mainfrom
seffhunnn:fix-disable-save-button-no-real-changes

Conversation

@seffhunnn
Copy link
Copy Markdown

@seffhunnn seffhunnn commented Mar 31, 2026

What does this PR do?

This PR fixes the event-type save button state by replacing the unreliable React Hook Form isDirty check with deep equality against a baseline reference.

The save button now:

  • stays disabled on initial load
  • enables only when actual form values differ from the baseline
  • disables again when changes are reverted
  • disables again after successful save via defaultValues baseline sync

Visual Demo (For contributors especially)

N/A (logic/state fix)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Navigate to an existing event type
  • Verify Save button is disabled on initial load
  • Change the title -> verify Save enables
  • Revert the title back to original -> verify Save disables again
  • Make a real change and save -> verify Save disables after successful save
  • No additional environment variables are required beyond standard local Cal.com setup

Checklist

  • My code follows the style guidelines of this project
  • I have self-reviewed the code and verified the PR remains focused to the event-type save button state bug
  • My changes generate no new warnings
  • This PR remains small and focused (<500 lines and <10 files)

@seffhunnn seffhunnn requested review from a team as code owners March 31, 2026 23:05
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/platform/atoms/event-types/hooks/useEventTypeForm.ts">

<violation number="1" location="packages/platform/atoms/event-types/hooks/useEventTypeForm.ts:219">
P2: Unsaved-change detection can go stale because `useMemo` depends only on `watchedValues` while baseline changes via non-reactive `ref` updates.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 31, 2026

CLA assistant check
All committers have signed the CLA.

@seffhunnn
Copy link
Copy Markdown
Author

Hi maintainers this is my first contribution to Cal.com.

This PR fixes the event-type save button state issue by using deep equality against a baseline reference so reverted changes correctly disable the Save button again.

Would appreciate a review and workflow approval when possible. Thank you!

Copy link
Copy Markdown
Contributor

@Ryukemeister Ryukemeister left a comment

Choose a reason for hiding this comment

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

hi there, thank you for your contribution. the issue that you've linked redirects to another PR which fixes the same issue. can you please link the correct issue? also are you able to reproduce this on your end? can you attach a visual demo of the fix before/after. we also need relevant tests for the fix.

@Ryukemeister Ryukemeister marked this pull request as draft April 1, 2026 12:46
@seffhunnn
Copy link
Copy Markdown
Author

hi there, thank you for your contribution. the issue that you've linked redirects to another PR which fixes the same issue. can you please link the correct issue? also are you able to reproduce this on your end? can you attach a visual demo of the fix before/after. we also need relevant tests for the fix.

Thanks for the review! I’ve updated the issue reference in the PR description to avoid auto-closing the linked issue.

I’m also reproducing the behavior locally and will attach a before/after visual demo along with relevant test coverage for the unsaved-change detection logic.

@seffhunnn
Copy link
Copy Markdown
Author

Pushed the requested updates ✅

Changes made:

  • corrected the linked issue reference
  • added the code walkthrough visual demo
  • added revert-to-baseline test coverage in useEventTypeForm.test.ts
  • attached the local passing test screenshot

The new test verifies that reverting values back to the original baseline correctly makes hasUnsavedChanges evaluate back to false.

2026-04-01.19-50-40.mp4
Screenshot 2026-04-01 200409

@seffhunnn seffhunnn marked this pull request as ready for review April 1, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-2924] [bug] events can be saved even if it is as same as before

3 participants