-
-
Notifications
You must be signed in to change notification settings - Fork 368
fix: show copy buttons on touch devices and fix aria-label mismatch #2203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
thealxlabs
wants to merge
7
commits into
npmx-dev:main
from
thealxlabs:fix/copy-buttons-touch-and-aria
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2e0000a
fix: show copy buttons on touch devices (#1771)
thealxlabs f029ccb
fix(a11y): match copy button aria-label to its visible text
thealxlabs 9c5a94e
test: add CopyToClipboardButton aria-label and touch visibility regre…
thealxlabs ed04748
[autofix.ci] apply automated fixes
autofix-ci[bot] 9d4be04
fix(a11y): increase provenance link touch target to meet 24px minimum
thealxlabs d0d6a82
fix(a11y): increase provenance link container gap for sufficient touc…
thealxlabs c0ca0bc
fix(a11y): revert touch-only copy button visibility to fix target-siz…
thealxlabs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { mountSuspended } from '@nuxt/test-utils/runtime' | ||
| import CopyToClipboardButton from '~/components/CopyToClipboardButton.vue' | ||
|
|
||
| describe('CopyToClipboardButton', () => { | ||
| it('aria-label matches visible copy text when copyText is provided', async () => { | ||
| const wrapper = await mountSuspended(CopyToClipboardButton, { | ||
| props: { | ||
| copied: false, | ||
| copyText: 'Copy package name', | ||
| }, | ||
| }) | ||
|
|
||
| const button = wrapper.find('button') | ||
| expect(button.attributes('aria-label')).toBe('Copy package name') | ||
| expect(button.text()).toContain('Copy package name') | ||
| }) | ||
|
|
||
| it('aria-label uses ariaLabelCopy when explicitly provided', async () => { | ||
| const wrapper = await mountSuspended(CopyToClipboardButton, { | ||
| props: { | ||
| copied: false, | ||
| copyText: 'Copy package name', | ||
| ariaLabelCopy: 'Copy the package name to clipboard', | ||
| }, | ||
| }) | ||
|
|
||
| const button = wrapper.find('button') | ||
| expect(button.attributes('aria-label')).toBe('Copy the package name to clipboard') | ||
| }) | ||
|
|
||
| it('aria-label reflects copiedText when copied is true', async () => { | ||
| const wrapper = await mountSuspended(CopyToClipboardButton, { | ||
| props: { | ||
| copied: true, | ||
| copyText: 'Copy package name', | ||
| copiedText: 'Copied!', | ||
| }, | ||
| }) | ||
|
|
||
| const button = wrapper.find('button') | ||
| expect(button.attributes('aria-label')).toBe('Copied!') | ||
| expect(button.text()).toContain('Copied!') | ||
| }) | ||
|
|
||
| it('aria-label matches visible text - no label/content mismatch', async () => { | ||
| const wrapper = await mountSuspended(CopyToClipboardButton, { | ||
| props: { | ||
| copied: false, | ||
| copyText: 'Copy install command', | ||
| }, | ||
| }) | ||
|
|
||
| const button = wrapper.find('button') | ||
| const ariaLabel = button.attributes('aria-label') ?? '' | ||
| const visibleText = button.text() | ||
| // The aria-label should equal the visible text (not some other string) | ||
| expect(visibleText).toContain(ariaLabel) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Final mismatch test uses a weak/reversed assertion for its stated intent.
This can pass when
aria-labelis only a substring of visible text, so it does not reliably guard against label/content-name mismatch.Proposed test tightening