Skip to content

Copy button in the Pandoc theme has no accessible name #4

Description

@t4k

The shared Pandoc theme adds a copy button to every code block. Its label is
an emoji set with innerHTML, and its only text alternative is a title
attribute:

copyButton.innerHTML = "📋";
copyButton.setAttribute("title", "Copy to Clipboard");

Problems:

  • title is not a reliable accessible name. Screen reader support for it is
    inconsistent, and it is unavailable to keyboard-only and touch users. The
    button announces as "clipboard", as the emoji name, or as nothing.
  • The confirmation state sets copyButton.textContent = "Copied!" with no live
    region, so the change is silent to assistive technology.
  • The button is appended to <pre> with no consideration of focus order.

Lives in pandoc/js/copyToClipboard.js. It reaches any repository that adopts
the shared docs build, so a fix here reaches all of them at once via @v1.

Not scoped yet — the right answer probably involves aria-label, a visible or
visually-hidden text label rather than an emoji, and an aria-live region for
the confirmation, but that needs someone to think it through properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions