Skip to content

Comments

fix: cancel event button for each booking on bookings page#23479

Merged
anikdhabal merged 5 commits intocalcom:mainfrom
ShashwatPS:shashwatps-cancelFix
Aug 31, 2025
Merged

fix: cancel event button for each booking on bookings page#23479
anikdhabal merged 5 commits intocalcom:mainfrom
ShashwatPS:shashwatps-cancelFix

Conversation

@ShashwatPS
Copy link
Contributor

@ShashwatPS ShashwatPS commented Aug 31, 2025

What does this PR do?

Booking cancellation is already handled internally when the Disable Cancelling option is enabled in the advanced setting ( as shown in the screenshot ) . However, the cancel button was still appearing, even when the prop to disable it was being passed to the component.

Screenshot 2025-08-31 at 3 55 16 PM
<DropdownItem
type="button"
color={cancelEventAction.color}
StartIcon={cancelEventAction.icon}
href={cancelEventAction.href}
onClick={cancelEventAction.onClick}
disabled={cancelEventAction.disabled}
data-bookingid={cancelEventAction.bookingId}
data-testid={cancelEventAction.id}
className={cancelEventAction.disabled ? "text-muted" : undefined}>
{cancelEventAction.label}
</DropdownItem>

The issue was traced to the DropdownItem component, which was not correctly respecting the disabled prop for elements that also had an href attribute. A small change was made to fix this.

const isLink = typeof href !== "undefined" && !props.disabled;

This change ensures the component respects the disabled prop, which mutes the button's text and makes it unclickable.

Visual Demo (After Fix)

https://www.loom.com/share/cc2f3ead2a884e6c827c7f1e1aba5886?sid=2f0a0f3c-c755-43c6-ad5d-c5bff28c18f0

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • 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?

  • Run the project locally
  • Create 2 event types, one with booking disabled and one with booking enabled
  • Make bookings from a different account, one for each event type.
  • Check the behavior of the cancel event button

Checklist

  • I have read the contributing guide
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have checked that my changes generate no new warnings

@ShashwatPS ShashwatPS requested review from a team as code owners August 31, 2025 10:54
@vercel
Copy link

vercel bot commented Aug 31, 2025

@ShashwatPS is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 31, 2025

Walkthrough

The change updates apps/web/components/booking/BookingListItem.tsx so that the Cancel dropdown item does not set an href when the action is disabled. Specifically, href is now conditional: href={cancelEventAction.disabled ? undefined : cancelEventAction.href}. Other props, including onClick and disabled, are unchanged. No exports or public APIs were altered.

Assessment against linked issues

Objective Addressed Explanation
Cancel action must not navigate or be actionable when cancellation is disabled [#23457, CAL-6353]
Cancel option should be hidden when cancellation is disabled [#23457, CAL-6353] The change conditions href only; visibility/conditional rendering is not modified.
Prevent 500 errors triggered by attempting cancel on managed event types with cancellation disabled [#23457, CAL-6353] Removing href likely blocks navigation, but without backend changes/tests, it’s unclear if all 500 paths are prevented.

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 or @coderabbit 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.

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 added the community Created by Linear-GitHub Sync label Aug 31, 2025
@github-actions github-actions bot added Low priority Created by Linear-GitHub Sync teams area: teams, round robin, collective, managed event-types 🐛 bug Something isn't working labels Aug 31, 2025
@dosubot dosubot bot added the bookings area: bookings, availability, timezones, double booking label Aug 31, 2025
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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/ui/components/dropdown/Dropdown.tsx (1)

148-159: Prevent accidental form submissions: default button type="button".

When isLink is false, this renders a <button> without an explicit type, which defaults to submit inside forms. Add an explicit type="button" and avoid passing disabled onto <a>.

Apply:

-  const ButtonOrLink = isLink ? "a" : "button";
-
-  const content = <ButtonOrLink {...props} />;
+  // Avoid passing `disabled` to <a>, and ensure buttons don't submit forms.
+  const { disabled, ...restProps } = props;
+  const content = isLink
+    ? <a {...restProps} />
+    : <button {...props} type={props.type ?? "button"} />;
🧹 Nitpick comments (6)
packages/ui/components/dropdown/Dropdown.tsx (6)

165-171: Improve disabled styling to truly “mute” and block hovers.

Current classes only set disabled:cursor-not-allowed; hover styles still apply visually. Add pointer-event and hover overrides.

-      className={classNames(
-        "hover:text-emphasis text-default inline-flex w/full items-center space-x-1 rounded-lg  p-2 disabled:cursor-not-allowed",
+      className={classNames(
+        "hover:text-emphasis text-default inline-flex w-full items-center space-x-1 rounded-lg p-2 disabled:cursor-not-allowed disabled:pointer-events-none disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-default",
         color === "destructive" ? "hover:bg-error hover:text-error text-error" : "hover:bg-subtle",
         props.className
       )}

144-159: Optional: modernize Link usage.

If/when you drop legacyBehavior project-wide, render the final element directly as Link’s child-free API and pass props to Link instead of <a>. Non-blocking here.


62-71: Type correctness: use Item props, not CheckboxItem.

DropdownMenuItem renders DropdownMenuPrimitive.Item but its props type is CheckboxItem. Align the types to avoid subtle prop mismatches.

-type DropdownMenuItemProps = ComponentProps<(typeof DropdownMenuPrimitive)["CheckboxItem"]>;
+type DropdownMenuItemProps = ComponentProps<(typeof DropdownMenuPrimitive)["Item"]>;

88-105: Localize a11y labels (“Active/Not active”).

Per repo guidelines, wrap user-facing strings with t(): Active / Not active should be localized.

Example (pseudo):

  • aria-label={typeof children === "string" ? t("notActive", { label: children }) : undefined}
  • aria-label={typeof children === "string" ? t("active", { label: children }) : undefined}

197-197: Prefer named exports over default.

Guideline: avoid default exports. Consider removing export default Dropdown; and rely on the named export.

-export default Dropdown;
+// Prefer named export; update imports accordingly where used.

161-181: Add an automated test to lock this behavior.

A lightweight RTL test: render DropdownItem with {href:"/x", disabled:true} and assert it renders a <button disabled> and not an <a>, and that hover styles don’t change. I can draft it if helpful.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5ebd335 and e408267.

📒 Files selected for processing (1)
  • packages/ui/components/dropdown/Dropdown.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.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/ui/components/dropdown/Dropdown.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/ui/components/dropdown/Dropdown.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/ui/components/dropdown/Dropdown.tsx
🔇 Additional comments (2)
packages/ui/components/dropdown/Dropdown.tsx (2)

145-156: Good fix: don’t render a link when disabled.

Gating isLink with !props.disabled resolves the UI/UX bug where disabled items with href were still navigable. This aligns the UI with server-side cancellation rules.


145-146: No usages of DropdownItem or ButtonOrLink with both href and disabled found; removing disabled‐link behavior is safe.

anikdhabal
anikdhabal previously approved these changes Aug 31, 2025
Copy link
Contributor

@anikdhabal anikdhabal left a comment

Choose a reason for hiding this comment

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

Nice find 🙏

@anikdhabal anikdhabal enabled auto-merge (squash) August 31, 2025 15:28
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: 0

🧹 Nitpick comments (1)
apps/web/components/booking/bookingActions.ts (1)

66-66: Avoid appending seatReferenceUid=undefined; compute once and guard.

If getSeatReferenceUid() returns undefined while seatsReferences.length is truthy, the URL will contain seatReferenceUid=undefined. Compute once and append only if defined.

-  const isDisabled = isActionDisabled("cancel", context);
+  const isDisabled = isActionDisabled("cancel", context);
+  const seatRefUid = getSeatReferenceUid();

-    href: isDisabled
-      ? undefined
-      : `/booking/${booking.uid}?cancel=true${
-          isTabRecurring && isRecurring ? "&allRemainingBookings=true" : ""
-        }${booking.seatsReferences.length ? `&seatReferenceUid=${getSeatReferenceUid()}` : ""}`,
+    href: isDisabled
+      ? undefined
+      : `/booking/${booking.uid}?cancel=true${
+          isTabRecurring && isRecurring ? "&allRemainingBookings=true" : ""
+        }${seatRefUid ? `&seatReferenceUid=${seatRefUid}` : ""}`,

Also applies to: 71-75

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e408267 and 62c0dc4.

📒 Files selected for processing (1)
  • apps/web/components/booking/bookingActions.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/web/components/booking/bookingActions.ts
**/*.{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:

  • apps/web/components/booking/bookingActions.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/components/booking/bookingActions.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Production builds / Build Web App
  • GitHub Check: Production builds / Build API v2
  • GitHub Check: Production builds / Build Atoms
  • GitHub Check: Production builds / Build API v1
  • GitHub Check: Tests / Unit
  • GitHub Check: Linters / lint
  • GitHub Check: Type check / check-types
🔇 Additional comments (2)
apps/web/components/booking/bookingActions.ts (2)

66-66: Good fix: cancel is now truly disabled (no link + disabled state).

Using isActionDisabled("cancel", ...) and dropping href when disabled prevents navigation and aligns UI with server constraints. Looks correct and matches the stated objective.

Also applies to: 71-75, 78-78


66-66: Verify DropdownItem link detection and ActionType.href optionality
Confirm that in DropdownItem’s isLink logic you’re gating href by !props.disabled, and that ActionType defines href as an optional field (href?: string).

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/web/components/booking/BookingListItem.tsx (1)

691-699: Standardize disabled+href logic across cancel entry points. In BookingListItem.tsx, the dropdown guard (href={cancelEventAction.disabled ? undefined : cancelEventAction.href}) is needed because neither DropdownItem nor TableActions strip href when disabled. Apply the same pattern to the <TableActions actions={[cancelEventAction]}> call (or update TableActions to unset href when disabled) so disabled cancel actions never render as active links.

🧹 Nitpick comments (1)
apps/web/components/booking/BookingListItem.tsx (1)

691-699: Also gate onClick when disabled (defense in depth).

Even though disabled should block interaction, explicitly removing the handler avoids edge cases and keeps semantics clear.

-                      <DropdownItem
+                      <DropdownItem
                         type="button"
                         color={cancelEventAction.color}
                         StartIcon={cancelEventAction.icon}
-                        href={cancelEventAction.disabled ? undefined : cancelEventAction.href}
-                        onClick={cancelEventAction.onClick}
+                        href={cancelEventAction.disabled ? undefined : cancelEventAction.href}
+                        onClick={cancelEventAction.disabled ? undefined : cancelEventAction.onClick}
                         disabled={cancelEventAction.disabled}
                         data-bookingid={cancelEventAction.bookingId}
                         data-testid={cancelEventAction.id}
                         className={cancelEventAction.disabled ? "text-muted" : undefined}>
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 62c0dc4 and 29befdd.

📒 Files selected for processing (1)
  • apps/web/components/booking/BookingListItem.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.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:

  • apps/web/components/booking/BookingListItem.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:

  • apps/web/components/booking/BookingListItem.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/components/booking/BookingListItem.tsx
🧠 Learnings (1)
📓 Common learnings
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
apps/web/components/booking/BookingListItem.tsx (1)

694-694: LGTM: preventing navigation when disabled.

Setting href to undefined when the action is disabled avoids accidental navigation and matches the objective.

@github-actions
Copy link
Contributor

E2E results are ready!

@anikdhabal anikdhabal merged commit 5f0188b into calcom:main Aug 31, 2025
34 of 38 checks passed
@ShashwatPS ShashwatPS deleted the shashwatps-cancelFix branch September 1, 2025 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working community Created by Linear-GitHub Sync Low priority Created by Linear-GitHub Sync ready-for-e2e teams area: teams, round robin, collective, managed event-types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancel button is visible on managed event types after disabling cancellation

2 participants