Skip to content

fix: show copy toast only after clipboard succeeds#29779

Open
nikhil008-git wants to merge 3 commits into
calcom:mainfrom
nikhil008-git:fix/clipboard-copy-feedback
Open

fix: show copy toast only after clipboard succeeds#29779
nikhil008-git wants to merge 3 commits into
calcom:mainfrom
nikhil008-git:fix/clipboard-copy-feedback

Conversation

@nikhil008-git

Copy link
Copy Markdown

What does this PR do?

On the event types list, the “link copied” success toast was shown before the clipboard write completed. If the clipboard API failed (e.g. permission denied or insecure context), users still saw a success message.

This PR:

  • Shows success/error toasts from copyToClipboard onSuccess / onFailure for public and private link copy buttons

  • Advances the private-link copy index only after a successful copy

  • Adds the copy_failed translation key

  • Fixes #XXXX (GitHub issue number)

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

  • N/A (toast-only behavior; no UI layout change)

Image Demo (if applicable):

  • N/A

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 if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works. (Manual verification only)

How should this be tested?

  • Are there environment variables that should be set? No
  • What are the minimal test data to have? A logged-in user with at least one event type (ideally also one with a private hashed link)
  • What is expected (happy path) to have (input and output)?
    • Click copy public link → success toast after clipboard write; paste confirms the URL
    • Click copy private link → success toast; private link rotates only on success
    • If clipboard fails → error toast (copy_failed), not success
  • Any other important info that could help to test that PR: Can simulate failure by denying clipboard permission in the browser

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 (N/A — small UX fix)
  • I have checked if my changes generate no new warnings
  • My PR is small (<500 lines and <10 files)

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @nikhil008-git! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 54fe5834-f69c-41ce-a54f-7e6d5e61ec91

📥 Commits

Reviewing files that changed from the base of the PR and between 0f2092d and b49e91a.

📒 Files selected for processing (1)
  • apps/web/modules/event-types/views/event-types-listing-view.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/modules/event-types/views/event-types-listing-view.tsx

📝 Walkthrough

Walkthrough

Updated desktop and mobile event link copy actions to handle clipboard success and failure callbacks. Success toasts now appear only after successful copies, private-link copy indices advance only on success, and failures show a new localized error toast.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: showing copy feedback only after clipboard success.
Description check ✅ Passed The description is directly related and accurately summarizes the clipboard toast and translation changes.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
apps/web/modules/event-types/views/event-types-listing-view.tsx (1)

771-775: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Update the mobile dropdown to use copyToClipboard.

The "copy link" action in the mobile dropdown menu was missed during this update and still uses navigator.clipboard.writeText directly, bypassing the new failure handling logic. I've also updated the data-testid to correctly reflect the copy action rather than duplicate.

💻 Proposed fix
-                                  data-testid={`event-type-duplicate-${type.id}`}
-                                  onClick={() => {
-                                    navigator.clipboard.writeText(calLink);
-                                    showToast(t("link_copied"), "success");
-                                  }}
+                                  data-testid={`event-type-copy-link-${type.id}`}
+                                  onClick={() => {
+                                    copyToClipboard(calLink, {
+                                      onSuccess: () => showToast(t("link_copied"), "success"),
+                                      onFailure: () => showToast(t("copy_failed"), "error"),
+                                    });
+                                  }}
🤖 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 `@apps/web/modules/event-types/views/event-types-listing-view.tsx` around lines
771 - 775, Update the mobile dropdown copy-link handler in the event types
listing view to call the shared copyToClipboard helper instead of
navigator.clipboard.writeText, preserving the success toast behavior and using
the corrected copy-action data-testid rather than the duplicate-action
identifier.
🤖 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.

Outside diff comments:
In `@apps/web/modules/event-types/views/event-types-listing-view.tsx`:
- Around line 771-775: Update the mobile dropdown copy-link handler in the event
types listing view to call the shared copyToClipboard helper instead of
navigator.clipboard.writeText, preserving the success toast behavior and using
the corrected copy-action data-testid rather than the duplicate-action
identifier.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2f1acdc1-e818-40e5-b962-7b8ac836ac43

📥 Commits

Reviewing files that changed from the base of the PR and between f004349 and f9600ca.

📒 Files selected for processing (2)
  • apps/web/modules/event-types/views/event-types-listing-view.tsx
  • packages/i18n/locales/en/common.json

@kartik-212004

Copy link
Copy Markdown
Member

can you fix the coderabbit suggestion for the mobile dropdown menu which was missed

@nikhil008-git

Copy link
Copy Markdown
Author

Hi @kartik-212004 addressed the change man
Could you please take another look, Thanks

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.

2 participants