Skip to content

Fix: lock timezone on booking page breaks atoms#23060

Merged
ibex088 merged 2 commits intomainfrom
fix/lock-timezone-on-booking-page-breaks-atoms
Aug 13, 2025
Merged

Fix: lock timezone on booking page breaks atoms#23060
ibex088 merged 2 commits intomainfrom
fix/lock-timezone-on-booking-page-breaks-atoms

Conversation

@ibex088
Copy link
Contributor

@ibex088 ibex088 commented Aug 13, 2025

What does this PR do?

EventTypeSettings Atom crashes on enabling Lock timezone on booking in advanced tab

  • Fixes #XXXX (GitHub issue number)
  • Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

  • Show screen recordings of the issue or feature.
  • Demonstrate how to reproduce the issue, the behavior before and after the change.

Image Demo (if applicable):

  • Add side-by-side screenshots of the original and updated change.
  • Highlight any significant change(s).

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. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@ibex088 ibex088 requested a review from a team August 13, 2025 10:41
@ibex088 ibex088 requested a review from a team as a code owner August 13, 2025 10:41
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

  • Adds a changeset for a minor release of @calcom/atoms documenting a fix related to “Lock timezone on booking.”
  • In EventAdvancedTab.tsx, introduces a memoized, platform-aware TimezoneSelect that switches between @calcom/atoms/timezone (platform) and the web TimezoneSelect based on isPlatform.
  • Updates the locked timezone UI to use the memoized selector.
  • In EventTypePlatformWrapper.tsx, refactors handleFormSubmit into a multi-line useCallback without altering logic or behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/lock-timezone-on-booking-page-breaks-atoms

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team August 13, 2025 10:41
@github-actions
Copy link
Contributor

github-actions bot commented Aug 13, 2025

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

Unknown release type "Fix" found in pull request title "Fix: lock timezone on booking page breaks atoms". 

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@keithwillcode keithwillcode added core area: core, team members only platform Anything related to our platform plan labels Aug 13, 2025
@dosubot dosubot bot added booking-page area: booking page, public booking page, booker 🐛 bug Something isn't working labels Aug 13, 2025
@graphite-app
Copy link

graphite-app bot commented Aug 13, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (08/13/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (08/13/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@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

🧹 Nitpick comments (3)
.changeset/deep-owls-hang.md (1)

2-2: Semver bump should be patch, not minor.

This is a bug fix with no public API change. Consider marking this as a patch release to align with semantic versioning expectations.

Apply this diff:

 ---
-"@calcom/atoms": minor
+"@calcom/atoms": patch
 ---
packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx (2)

13-17: Typo in alias; improve naming clarity.

Rename PlatformTimzoneSelectPlatformTimezoneSelect to avoid confusion and keep naming consistent with “Timezone.”

Apply this diff:

-import { Timezone as PlatformTimzoneSelect } from "@calcom/atoms/timezone";
+import { Timezone as PlatformTimezoneSelect } from "@calcom/atoms/timezone";

569-572: Simplify: use direct conditional instead of useMemo for component selection.

useMemo isn’t needed here; the component refs are stable and cheaper than the extra hook. A direct conditional improves readability. Also, ensure both platform/web variants share the same props (notably the onChange signature).

Apply this diff to simplify:

-  const TimezoneSelect = useMemo(() => {
-    return isPlatform ? PlatformTimzoneSelect : WebTimezoneSelect;
-  }, [isPlatform]);
+  const TimezoneSelect = isPlatform ? PlatformTimezoneSelect : WebTimezoneSelect;

Verification request:

  • Confirm that both @calcom/atoms/timezone Timezone and web TimezoneSelect accept the same props and emit the same onChange shape. The current usage expects an object with a .value string. If the platform variant returns a raw string, update the handler to normalize both:

Example outside this hunk (for clarity only):

<TimezoneSelect
  id="lockedTimeZone"
  value={value ?? "Europe/London"}
  onChange={(e: { value: string } | string) => {
    const tz = typeof e === "string" ? e : e?.value;
    if (tz) formMethods.setValue("lockedTimeZone", tz, { shouldDirty: true });
  }}
/>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 94a04f0 and 1c5bfc3.

📒 Files selected for processing (3)
  • .changeset/deep-owls-hang.md (1 hunks)
  • packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx (3 hunks)
  • packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx
  • packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx
  • packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx
🧬 Code Graph Analysis (1)
packages/features/eventtypes/components/tabs/advanced/EventAdvancedTab.tsx (1)
packages/features/components/timezone-select/TimezoneSelect.tsx (1)
  • TimezoneSelect (42-60)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Detect changes
🔇 Additional comments (1)
packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx (1)

154-156: Good: propagate error to external callbacks.

Forwarding a normalized error to callbacksRef.current?.onError ensures external consumers get notified on failures triggered by the update mutation.

Comment on lines +178 to +198
const handleFormSubmit = useCallback(
(customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
if (customCallbacks) {
callbacksRef.current = customCallbacks;
}

if (saveButtonRef.current) {
saveButtonRef.current.click();
} else {
form.handleSubmit((data) => {
try {
handleSubmit(data);
customCallbacks?.onSuccess?.();
} catch (error) {
customCallbacks?.onError?.(error as Error);
}
})();
}
}, [handleSubmit, form]);
if (saveButtonRef.current) {
saveButtonRef.current.click();
} else {
form.handleSubmit((data) => {
try {
handleSubmit(data);
customCallbacks?.onSuccess?.();
} catch (error) {
customCallbacks?.onError?.(error as Error);
}
})();
}
},
[handleSubmit, form]
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid duplicate/early success callbacks in handleFormSubmit.

customCallbacks?.onSuccess?.() is invoked immediately after handleSubmit(data), which likely fires an async mutation. This will:

  • Call onSuccess too early (before the mutation settles).
  • Potentially call onSuccess twice (here and again in updateMutation.onSuccess via callbacksRef).

Rely on mutation callbacks (already wired via callbacksRef) and remove the immediate invocations in this handler.

Apply this diff:

-  const handleFormSubmit = useCallback(
-    (customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
-      if (customCallbacks) {
-        callbacksRef.current = customCallbacks;
-      }
-
-      if (saveButtonRef.current) {
-        saveButtonRef.current.click();
-      } else {
-        form.handleSubmit((data) => {
-          try {
-            handleSubmit(data);
-            customCallbacks?.onSuccess?.();
-          } catch (error) {
-            customCallbacks?.onError?.(error as Error);
-          }
-        })();
-      }
-    },
-    [handleSubmit, form]
-  );
+  const handleFormSubmit = useCallback(
+    (customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
+      if (customCallbacks) {
+        callbacksRef.current = customCallbacks;
+      }
+      if (saveButtonRef.current) {
+        // Triggers the underlying submit which will call mutation and invoke callbacksRef on settle
+        saveButtonRef.current.click();
+        return;
+      }
+      // Fallback: submit programmatically; rely on mutation onSuccess/onError to invoke callbacksRef
+      form.handleSubmit((data) => {
+        handleSubmit(data);
+      })();
+    },
+    [handleSubmit, form]
+  );
📝 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
const handleFormSubmit = useCallback(
(customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
if (customCallbacks) {
callbacksRef.current = customCallbacks;
}
if (saveButtonRef.current) {
saveButtonRef.current.click();
} else {
form.handleSubmit((data) => {
try {
handleSubmit(data);
customCallbacks?.onSuccess?.();
} catch (error) {
customCallbacks?.onError?.(error as Error);
}
})();
}
}, [handleSubmit, form]);
if (saveButtonRef.current) {
saveButtonRef.current.click();
} else {
form.handleSubmit((data) => {
try {
handleSubmit(data);
customCallbacks?.onSuccess?.();
} catch (error) {
customCallbacks?.onError?.(error as Error);
}
})();
}
},
[handleSubmit, form]
);
const handleFormSubmit = useCallback(
(customCallbacks?: { onSuccess?: () => void; onError?: (error: Error) => void }) => {
if (customCallbacks) {
callbacksRef.current = customCallbacks;
}
if (saveButtonRef.current) {
// Triggers the underlying submit which will call mutation and invoke callbacksRef on settle
saveButtonRef.current.click();
return;
}
// Fallback: submit programmatically; rely on mutation onSuccess/onError to invoke callbacksRef
form.handleSubmit((data) => {
handleSubmit(data);
})();
},
[handleSubmit, form]
);
🤖 Prompt for AI Agents
In packages/platform/atoms/event-types/wrappers/EventTypePlatformWrapper.tsx
around lines 178-198, remove the immediate invocations of
customCallbacks?.onSuccess and customCallbacks?.onError inside the
form.handleSubmit branch so callbacks are only invoked via the mutation
callbacks wired through callbacksRef; keep the assignment callbacksRef.current =
customCallbacks when provided and still call saveButtonRef.current.click() when
present, but inside the form.handleSubmit try/catch do not call customCallbacks
directly — let updateMutation.onSuccess/onError (via callbacksRef) handle
success/error notifications.

@ibex088 ibex088 enabled auto-merge (squash) August 13, 2025 12:51
@github-actions
Copy link
Contributor

github-actions bot commented Aug 13, 2025

E2E results are ready!

@ibex088 ibex088 merged commit 293dd1a into main Aug 13, 2025
102 of 109 checks passed
@ibex088 ibex088 deleted the fix/lock-timezone-on-booking-page-breaks-atoms branch August 13, 2025 13:03
@coderabbitai coderabbitai bot mentioned this pull request Sep 22, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

booking-page area: booking page, public booking page, booker 🐛 bug Something isn't working core area: core, team members only platform Anything related to our platform plan ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants