Skip to content

Conversation

M1n01
Copy link
Contributor

@M1n01 M1n01 commented Aug 1, 2025

Description

This PR adds an aria-label attribute to the CodeHighlight copy button to improve accessibility for screen reader users.

Problem

Currently, the copy button in CodeHighlight component doesn't have an accessible name, which causes:

  • Screen readers announce it as just "button" without context
  • Accessibility test failures (e.g., in PageSpeed Insights)
  • Poor experience for users relying on assistive technologies

Solution

Added aria-label attribute to the CodeHighlightControl component in CopyCodeButton:

  • When not copied: "Copy code"
  • When copied: "Copied"

This follows the same pattern used in other Mantine components like Burger.

Changes

  • Added aria-label prop to CodeHighlightControl in CopyCodeButton component
  • The label dynamically changes based on the clipboard state

Testing

  • Tested manually in Storybook
  • Verified the button now has proper accessible name in browser DevTools
  • No existing tests for CopyCodeButton component to update

Note

This is a minimal accessibility fix that only adds the aria-label prop. No breaking changes or new features introduced.

Checklist

  • I've followed the project's contribution guidelines
  • The code follows the existing code style
  • The change is backward compatible
  • This is a small accessibility fix that doesn't require prior discussion

@rtivital rtivital merged commit ab43b62 into mantinedev:master Aug 7, 2025
@rtivital
Copy link
Member

rtivital commented Aug 7, 2025

Thanks!

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.

2 participants