-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Accessibility: links need role="button" #1717
Comments
Just encountered the same issue today, since the container element is an acnhor tag it messes up the announcements by assistive technology. I played around a bit and found out that we can use other element as the <ul class="project-grid">
{#each projects as project}
<li on:keydown={triggerPSWP} tabindex="0" aria-label="{project.title} Project: {project.description}" class="project-card">
<!--
Hiding the actual pswp anchor element as the first child of our
registered pswp children element (project-card). Hidden for both screen reader and visual users
-->
<a href={project.imageURL} target="_blank" rel="noreferrer" data-pswp-width="2500" data-pswp-height="1200" aria-hidden="true" class="pswp-link hidden">{ project.title }</a>
<!-- Other content here -->
</li>
{/each}
</ul> Our pswp gallery is the element with a class of Now if we click on the function triggerPSWP(event) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
const pswpTrigger = event.target
if (pswpTrigger instanceof HTMLElement) {
const pswpLink = pswpTrigger.querySelector('.pswp-link')
if (pswpLink instanceof HTMLAnchorElement) {
pswpLink.click()
}
}
}
} With this PSWP is now accessible friendly! 🎉 |
After initializing the plugin, links are still look like links to assistive technologies. Assistive technologies do not know these links will trigger a dialog.
So the links need
role="button"
andtabindex="0"
and thehref
attributes would need to be removed.The text was updated successfully, but these errors were encountered: