w3c / html-aria

ARIA in HTML
https://w3c.github.io/html-aria/
Other
178 stars 48 forks source link

<a> tag with href attribute but also negative tabindex attribute value - should this be treated differently? #490

Closed giacomo-petri closed 8 months ago

giacomo-petri commented 8 months ago

In the context of the ARIA in HTML document, the a HTML element with href attribute accepts only specific roles, and these roles do not include presentation or none.

However, there may be scenarios where an author intends to create a large clickable area for pointer device users while maintaining a meaningful and concise link for assistive technology users, such as screen reader users. To address this, a solution has been implemented as follows:

<ul>
    <li class="product-list-item" style="border:1px solid #aaa">
        <a style="display:block" href="product1">Product name</a>
        <a style="display:block" href="product1" role="presentation" tabindex="-1">
            <div>
                <img src="prod1.png" alt="product name">
            </div>
            <div>Short description</div>
            <div>Colors available: Black</div>
            <div>$1811.89</div>
            <div role="img" aria-label="Rating: 4 out of 5 stars">
                <img src="filled-star.png" alt="">
                <img src="filled-star.png" alt="">
                <img src="filled-star.png" alt="">
                <img src="filled-star.png" alt="">
                <img src="empty-star.png" alt="">
            </div>
        </a>
    </li>
    ...
</ul>

From an ARIA in HTML perspective, this approach is not currently considered acceptable. The Presentational Roles Conflict Resolution does not apply in this case, as the a element, even if with an href attribute, is not focusable.

Should we consider this scenario as acceptable by adding a note to the "ARIA role, state, and property allowances" column and clarifying that if the a element is not included in sequential focus navigation (indicated by a negative tabindex attribute value) it should be treated differently allowing any role?

I don't see any compelling reason for this approach to fail in terms of accessibility, and if you agree, I'm more than happy to propose changes in a pull request.

scottaohara commented 8 months ago

The presentation roles conflict resolution does apply. You are mixing up something being tabbable with something being focusable. tabindex=-1 is still focusable so to then is the conflict resolution. This isn't just aria in html saying no, it's ARIA's rule that this spec is only clarifying.