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 `<h1/>`. 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.
This commit is contained in:
Nolan Darilek 2021-05-25 15:43:09 -05:00 committed by GitHub
parent a363f47798
commit 549e100d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -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,
},