A11Y: Hide post avatar link from screen readers

A11Y: Hide post avatar link from screen readers

diff --git a/app/assets/javascripts/discourse/app/widgets/post.js b/app/assets/javascripts/discourse/app/widgets/post.js
index d93f410..a63263e 100644
--- a/app/assets/javascripts/discourse/app/widgets/post.js
+++ b/app/assets/javascripts/discourse/app/widgets/post.js
@@ -64,7 +64,11 @@ export function avatarFor(wanted, attrs) {
       className: `trigger-user-card ${attrs.className || ""}`,
-      attributes: { href: attrs.url, "data-user-card": attrs.username },
+      attributes: {
+        href: attrs.url,
+        "data-user-card": attrs.username,
+        "aria-hidden": true,
+      },
     avatarImg(wanted, attrs)

GitHub sha: 6977f782

In a previous commit I removed the title attribute from post avatars because they’re decorative and shouldn’t be read by screen readers (which is why they have an empty alt tag), this hides the avatar link itself.

The avatar and link are redundant, a screen reader will get the same content from the post’s name/username and the associated link.

1 Like