Skip to content

AddressDisplay copy-to-clipboard silently fails in non-HTTPS contexts with no fallback or aria-label #586

Description

@k-deejah

Problem

src/components/AddressDisplay.tsx copies the wallet address using the Clipboard API with a silent catch:

navigator.clipboard.writeText(address).catch(() => {
  /* fallback */
});

The comment says "fallback" but there is no actual fallback implementation. navigator.clipboard requires a secure context (HTTPS). In HTTP environments — local dev served over plain HTTP, CI preview deployments, or embedded webviews — navigator.clipboard is undefined and the copy button silently does nothing. Users get no feedback that the copy failed.

A second problem in the same file: the copy button element has no aria-label. Screen readers announce it as an unlabeled button, giving keyboard and assistive-technology users no indication of what the button does or which address it will copy.

Solution

  1. Add a document.execCommand('copy') fallback via a temporary <textarea> element for non-HTTPS contexts:
navigator.clipboard.writeText(address).catch(() => {
  const el = document.createElement('textarea');
  el.value = address;
  el.style.position = 'fixed';
  el.style.opacity = '0';
  document.body.appendChild(el);
  el.select();
  document.execCommand('copy');
  document.body.removeChild(el);
});
  1. Add aria-label={copied ? 'Copied!' : 'Copy address to clipboard'} to the button.

Acceptance Criteria

  • Copying works in both HTTPS and plain HTTP contexts
  • The copy button has a descriptive aria-label that updates after a successful copy
  • When both clipboard methods fail, an error icon or message is shown for 2 seconds
  • The 2-second "Copied" reset timeout still works after the fix
  • No regressions in the existing copy behavior in secure contexts

Note for Contributors: If you're assigned to this issue, write a clear and detailed description for your pull request. Explain what was changed, why it was needed, how it was implemented, and include any relevant testing or screenshots where applicable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programaccessibilityA11y, ARIA, keyboard navigation, screen readersbugSomething isn't workingfrontendUI, component, or visual layer concern

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions