-
Notifications
You must be signed in to change notification settings - Fork 338
feat(link): add aria-* attribute #4076
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
Conversation
WalkthroughEnhanced accessibility of a Vue link component by adding ARIA attributes (aria-disabled, tabindex, aria-label, aria-hidden) to the anchor and icon elements for improved keyboard navigation and screen reader support. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@packages/vue/src/link/src/pc.vue`:
- Around line 29-35: The template currently sets aria-hidden="true" on the
<component :is="icon" ... /> which hides icon-only links from AT when there is
no text (slots.default or value) and no aria-label; update the logic so
aria-hidden is only applied when there is visible text (i.e., when slots.default
|| value is truthy), otherwise do not set aria-hidden and instead surface a
dev-time warning if neither value, slots.default nor an explicit aria-label is
provided; locate the icon-rendering component in the template (the <component
:is="icon" ... />) and implement the conditional aria-hidden and warning (use
process.env.NODE_ENV or a similar dev check) so icon-only links remain
accessible by default.
- Around line 25-27: The v-bind spread with a($attrs, ['^on[A-Z]']) duplicates
aria-label because $attrs already includes it; update the spread to exclude
aria-label (e.g., add 'aria-label' to the exclusion list passed to
filterAttrs/a) so the component only sets aria-label once via the explicit
:aria-label="$attrs['aria-label'] || value", or alternatively remove the
explicit binding and rely on the spread — modify the call site of a(...) in the
template to exclude 'aria-label' to eliminate redundancy.
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit