Copy to clipboard title#163
Closed
moskvin wants to merge 3 commits into
Closed
Conversation
Contributor
Danger ReportNo issues found. |
40b9a30 to
14eb3ec
Compare
There was a problem hiding this comment.
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-clipboardelements 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); | ||
| } | ||
| }); | ||
| }); |
Member
|
Shouldn't this be a swagger UI feature? |
Contributor
Author
I believe so. I'll try to help the Swagger UI team investigate and potentially fix the issue. |
Contributor
Author
Contributor
Author
|
@dblock I'll close the PR without merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.