-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
"The href attribute is required for an anchor to be keyboard accessible." is in contradiction to W3 "Using ARIA" in relation to links #906
Comments
Well, this one has me thinking! @asos-francesca, first question, what is the purpose of a disabled hyperlink in the case that you are trying to support? I'm trying to understand why a link would be disabled, like what that means semantically. Perhaps there is a good reason that the disabled attribute can't be applied to Second question, could you just use a I'm not convinced that we need to support this edge case, but maybe I'm missing something that came up in the case you're trying to support. |
@jessebeach thanks for the response! We have a list of links that contains alternative colour options for a product. We want to express to the user that the links cannot be clicked because one colour is out of stock, but we still want to express to the user that alternative colour options are in existence, even if they are not available right now. For our visual frontend we display a greyed out image for these out of stock items, whereas the other items are in colour. The aria label explains this difference too with a label expressing colour and status, "Red. Out of Stock". We thought a lot about the semantics of what to make this unclickable link. That was what lead us to the W3C suggestion of the instance of a placeholder link, it seemed to suggest that was the right pattern. There is clearly a convention for disabled links as expressed here: https://w3c.github.io/html-aria/#example-communicate-a-disabled-link-with-aria That's why we went with this convention. The eslint ruling seems to state that you cannot have an without a href but the a11y guidelines across the web seem to suggest this is valid, as long as the https://a11y-guidelines.orange.com/en/articles/disable-elements/ |
Why wouldn't you want these "out of stock" links to still link to the product page for that color? (If there's no per-color pages, then i'd suspect none of them should be links, and instead should be buttons) |
Hmm, good point. If the the user is just picking a color, but not navigating to a new page, then the link is indeed the wrong role. When a link is activated, the user navigates to a place. So if the list of colors is mutually exclusive, then the best semantic concept is a radio group. If the list of colors is not mutually exclusive, then the best semantic concept is a button group with selected colors indicated with That does still leave us with how to handle the w3c recommendation for a disabled link, which is a problem that still intrigues me. I think that
It's not generally well known that many elements that seem to be semantic do not in fact have an AX Tree analog node. |
By the way @asos-francesca this was a very good question. It got me thinking for a few days. I think the conclusion here is to leave Let me know if you disagree. This is definitely an open discussion. You certainly discovered a debatable topic. |
We have followed the convention laid out for disabling a link to make it accessible, laid out by w3c here: https://w3c.github.io/html-aria/#example-communicate-a-disabled-link-with-aria
This example suggests that a link that would otherwise be active, but currently is not, should be expressed as an anchor with no href, e.g:
Communicate a disabled link with ARIA:
<a role=link aria-disabled=true>...</a>
However the eslint rule
jsx-a11y/anchor-is-valid
states:This seems to be in contravention to the w3c standard which the eslint rule actually links back to.
I suggest this eslint rule should be updated to allow anchor tags with no href as long as both
role=link
andaria-disabled=true
are included.The text was updated successfully, but these errors were encountered: