Skip to content

Add accessible names and WCAG checks for buttons#10908

Open
moskvin wants to merge 5 commits into
swagger-api:masterfrom
moskvin:master
Open

Add accessible names and WCAG checks for buttons#10908
moskvin wants to merge 5 commits into
swagger-api:masterfrom
moskvin:master

Conversation

@moskvin
Copy link
Copy Markdown

@moskvin moskvin commented May 27, 2026

Adds accessible names and tooltips to Swagger UI icon buttons

This updates copy controls for:

  • operation path copy buttons
  • cURL command copy buttons
  • syntax-highlighted code copy buttons
  • request snippet copy buttons

The labels are applied directly to the interactive <button> elements. Matching title and aria-label values are also applied to the .copy-to-clipboard wrappers where applicable, preserving the existing wrapper styling while giving assistive technology a programmatic name for the actual control.

Motivation and Context

Some copy-to-clipboard controls render as empty buttons without accessible names. Screen readers and accessibility scanners cannot determine what those controls do.

This fixes the cURL copy-button issue reported in:

Fixes #9584

It also addresses the copy-to-clipboard portion of the broader accessibility issue:

Relates to #10699

This change removes the need for downstream runtime workarounds such as ruby-grape/grape-swagger-rails#163, where .copy-to-clipboard elements were being labeled after render with a MutationObserver.

How Has This Been Tested?

Tested in the local Swagger UI repository with Node/npm project tooling.

Commands run:

npx eslint src/core/components/copy-to-clipboard-btn.jsx src/core/components/curl.jsx src/core/plugins/syntax-highlighting/components/HighlightCode.jsx src/core/plugins/request-snippets/request-snippets.jsx

ESLint completed with no errors. It still reports existing react/jsx-no-bind warnings in unchanged code paths.

npm run test:unit -- --runInBand test/unit/components/highlight-code.jsx

Result:

Test Suites: 1 passed, 1 total
Tests: 3 passed, 3 total

Screenshots (if appropriate):

N/A. This is an accessibility markup change and does not intentionally change the visual UI.

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

@moskvin moskvin changed the title Adds accessible names and tooltips to Swagger UI copy-to-clipboard controls. Add accessible names and WCAG checks for buttons May 27, 2026
@moskvin
Copy link
Copy Markdown
Author

moskvin commented May 28, 2026

Hi @robert-hebel-sb - sorry to ping directly, I noticed you've been merging most of the recent PRs and was hoping you (or someone you'd suggest) could take a look at this one when you have a moment.

It's a small, self-contained accessibility change:

Happy to rebase, split it up, or adjust the wording on the labels if any of that would make the review easier. Thanks for your time!

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.

a11y: Curl command's copy to clipboard button has accessibility issues

1 participant