Skip to content

Guard missing contact-card clipboard helper#102

Merged
VatsalSy merged 1 commit into
mainfrom
local-branch/contact-card-copy-guard
Jul 17, 2026
Merged

Guard missing contact-card clipboard helper#102
VatsalSy merged 1 commit into
mainfrom
local-branch/contact-card-copy-guard

Conversation

@VatsalSy

Copy link
Copy Markdown
Member

Summary

  • Prevent the contact card from throwing before its existing copy-error handling when the shared clipboard helper is unavailable
  • Address the concrete post-merge review finding on PR Add in-house contact card #101

Changes

  • Add optional chaining to the copyToClipboard method call in assets/js/contact-card.js
  • Keep the existing fallback status message and control flow unchanged

Testing

  • npm test -- --runInBand contact-card.test.js (6 tests passed)
  • ./scripts/lint-check.sh (passed)
  • git diff --check (passed)

Evidence

Avoid throwing before the contact card's existing error handling when the shared utility object is present but copyToClipboard is unavailable.
Copilot AI review requested due to automatic review settings July 17, 2026 12:19
@VatsalSy VatsalSy self-assigned this Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the /contact-card/ clipboard path by ensuring the page doesn’t throw a TypeError when window.Utils exists but its copyToClipboard helper is missing, allowing the existing “copy failed” status handling to run as intended.

Changes:

  • Guard the copyToClipboard invocation with optional-call chaining (?.(...)) so a missing helper yields a controlled failure (copied falsy) instead of an exception.
  • Preserve existing fallback status messages and control flow for both “Copy email” and “Share card” actions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@VatsalSy
VatsalSy merged commit 723b095 into main Jul 17, 2026
4 checks passed
@VatsalSy
VatsalSy deleted the local-branch/contact-card-copy-guard branch July 17, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants