Skip to content

Clipboard copy can fail silently when Clipboard API is unavailable #400

Description

@murongg

What happens

The shared clipboard helper calls navigator.clipboard.writeText(...) directly and immediately shows a success toast. If the Clipboard API is unavailable or rejects the write, the action can fail silently from the user's perspective.

One visible place this affects is the organization invite table: clicking Copy invite link can show a copied toast while the system clipboard remains unchanged.

Why it happens

apps/start/src/utils/clipboard.ts does not currently:

  • handle browsers/environments where navigator.clipboard is unavailable
  • catch writeText rejections such as permission or insecure-context failures
  • provide a fallback copy path
  • show an error toast when copying fails

Expected behavior

When Clipboard API copy fails, OpenPanel should attempt a browser-compatible fallback. If all copy methods fail, the UI should show a failure message instead of a success message.

Proposed fix

Add a fallback copy implementation using a temporary textarea and document.execCommand('copy'), and only show the success toast after one copy method succeeds. Show an error toast when both methods fail.

I have a small PR ready with a regression test for this behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions