Skip to content

Copy to clipboard title#163

Closed
moskvin wants to merge 3 commits into
masterfrom
copy-to-clipboard-title
Closed

Copy to clipboard title#163
moskvin wants to merge 3 commits into
masterfrom
copy-to-clipboard-title

Conversation

@moskvin

@moskvin moskvin commented May 26, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Danger Report

No issues found.

View run

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 addresses missing accessible labeling on Swagger UI “copy to clipboard” controls by ensuring .copy-to-clipboard elements receive a title (tooltip) and aria-label (screen readers), and adds a feature spec to prevent regressions.

Changes:

  • Add runtime labeling for .copy-to-clipboard elements on initial render and subsequent DOM updates (MutationObserver).
  • Add a feature spec asserting all copy-to-clipboard elements are labeled.
  • Update compiled JS assets and changelog entry.

Reviewed changes

Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
spec/features/swagger_spec.rb Adds a feature spec + helper to detect unlabeled .copy-to-clipboard elements.
frontend/grape_swagger_rails/index.ts Adds labelCopyButtons and a MutationObserver to apply title/aria-label during Swagger UI renders.
CHANGELOG.md Adds release note entry for the change.
app/assets/javascripts/grape_swagger_rails/index.js Updates built (unminified) JS output for the new labeling behavior.
app/assets/javascripts/grape_swagger_rails/index.min.js Updates built minified JS output for the new labeling behavior.
app/assets/javascripts/grape_swagger_rails/index.min.js.map Updates sourcemap for the rebuilt JS bundle.

Comment on lines +287 to +291

unlabeled = find_unlabeled_copy_buttons

expect(unlabeled).to be_empty,
"Expected all .copy-to-clipboard elements to be labeled. Got: #{unlabeled.inspect}"
Comment on lines +57 to +61
const targets =
root instanceof Element && root.matches(".copy-to-clipboard")
? [root, ...Array.from(root.querySelectorAll(".copy-to-clipboard"))]
: Array.from(root.querySelectorAll(".copy-to-clipboard"));

Comment on lines +369 to +376
new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
labelCopyButtons(node as Element);
}
});
});
@dblock

dblock commented May 26, 2026

Copy link
Copy Markdown
Member

Shouldn't this be a swagger UI feature?

@moskvin

moskvin commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Shouldn't this be a swagger UI feature?

I believe so. I'll try to help the Swagger UI team investigate and potentially fix the issue.

@moskvin

moskvin commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

@moskvin

moskvin commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

@dblock I'll close the PR without merge

@moskvin moskvin closed this May 28, 2026
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.

3 participants