fix: show copy toast only after clipboard succeeds#29779
Conversation
|
Welcome to Cal.diy, @nikhil008-git! 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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughUpdated 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)
✨ 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.
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 winUpdate 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.writeTextdirectly, bypassing the new failure handling logic. I've also updated thedata-testidto 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
📒 Files selected for processing (2)
apps/web/modules/event-types/views/event-types-listing-view.tsxpackages/i18n/locales/en/common.json
|
can you fix the coderabbit suggestion for the mobile dropdown menu which was missed |
|
Hi @kartik-212004 addressed the change man |
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
copyToClipboardonSuccess/onFailurefor public and private link copy buttonsAdvances the private-link copy index only after a successful copy
Adds the
copy_failedtranslation keyFixes #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):
Image Demo (if applicable):
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
copy_failed), not successChecklist