From 549e100d8cc44c9fdd4edde9e0dc20af6321a1b1 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 25 May 2021 15:43:09 -0500 Subject: [PATCH] A11Y: Add heading role for post titles. (#13143) Not all screen readers treat articles as navigable roles when moving between landmarks. To help with this, we use a `heading` role on the title, with an arbitrary depth of 2 chosen as to not conflict with the main `

`. Because ARIA roles are used, this change should be entirely non-visual. While this introduces minor navigation challenges in posts where headers are included, the vast majority of posts don't, and as screen reader users, we're used to mixed headers in longer-form content. --- app/assets/javascripts/discourse/app/widgets/post.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/assets/javascripts/discourse/app/widgets/post.js b/app/assets/javascripts/discourse/app/widgets/post.js index f1afc5f6144..c2e2bfd48c8 100644 --- a/app/assets/javascripts/discourse/app/widgets/post.js +++ b/app/assets/javascripts/discourse/app/widgets/post.js @@ -247,6 +247,13 @@ function showReplyTab(attrs, siteSettings) { createWidget("post-meta-data", { tagName: "div.topic-meta-data", + buildAttributes() { + return { + role: "heading", + "aria-level": "2", + }; + }, + settings: { displayPosterName: true, },