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
Redundant links #146
Comments
As a free gift here is how I fix it on my projects: 1- only one link, the more meaningful, on any embedded entity (function ($, Drupal) {
'use strict';
/**
* Handle click on a node so it redirects to the location of its first link.
*/
Drupal.behaviors.clickableNode = {
attach: function (context, settings) {
$('.js-clickable-node').once('clickableNode')
.on('mouseup.clickableNode', function (evt) {
var $target = $(evt.currentTarget);
// Ensure we didn't click on a link or a button.
if ($target.is('a, button') || $target.parents('a, button').length) {
return;
}
// Avoid other handlers or default behavior to be triggered, then
// redirect the user.
evt.stopImmediatePropagation();
evt.preventDefault();
var $link = $target.find('a').filter(function () {
return $(this).parents('.contextual').length === 0;
});
if (evt.shiftKey || evt.ctrlKey || evt.button === 1) {
window.open($link.attr('href'), '_blank');
}
else {
location.href = $link.attr('href');
}
})
// Add a visual effect when focusing links inside the content.
.find('a')
.on('focus', function (evt) {
$(evt.target).parents('.js-clickable-node').addClass('is-active');
})
.on('blur', function (evt) {
$(evt.target).parents('.js-clickable-node').removeClass('is-active');
});
}
};
})(jQuery, Drupal); |
I forgot to mention that, even if there is not a full browser support, using the CSS focus-within pseudo class is a good way to have a great UX even for keyboard users :) |
3 links in a row is repetitive for keyboard traversal, and it would be good to reduce this. Surely it's not a failure of WCAG 2.4.4 though? I can't see anything in the understanding docs for 2.4.4 which relate to this. |
It's not directly failing criterions but it can be understood from H2: Combining adjacent image and text links for the same resource where we can read:
I suppose we could also interpret G197: Using labels, names, and text alternatives consistently for content that has the same functionality which says:
But I'm not sure it applies on common links. |
Yes, H2 is relevant, and worth trying. |
Does this have an equivalent issue on drupal.org yet? |
The card teasers on this site include three links to the same URL. This is considered an alert by WCAG (2.4.4 Link Purpose - Level A).
Example
The image, title, and recipe link all go to the
/web/recipes/glorious-salad
nodeWhy It Matters
When adjacent links go to the same location (such as a linked product image and an adjacent linked product name that go to the same product page) this results in additional navigation and repetition for keyboard and screen reader users.
How to Fix It
If possible, combine the redundant links into one link and remove any redundant text or alternative text (for example, if a product image and product name are in the same link, the image can usually be given alt="").
See http://a11y-style-guide.com/style-guide/section-general.html#kssref-general-read-more for some "read more" examples to avoid one redundancy issue. Might consider making the entire card teaser a link or removing the link off of the image.
The text was updated successfully, but these errors were encountered: