UX: add ARIA region role to posts (#13130)

UX: add ARIA region role to posts (#13130)

NVDA does not detect HTML5 articles as regions. This explicitly sets a region with an aria-label denoting post numbers making it much easier to know where you are in a topic.

Note role: article which is more semantically correct is not respected by NVDA d/D shortcut, hence the much more generic “region” role.

diff --git a/app/assets/javascripts/discourse/app/widgets/post.js b/app/assets/javascripts/discourse/app/widgets/post.js
index 9a02a73..f1afc5f 100644
--- a/app/assets/javascripts/discourse/app/widgets/post.js
+++ b/app/assets/javascripts/discourse/app/widgets/post.js
@@ -596,6 +596,10 @@ createWidget("post-article", {
 
   buildAttributes(attrs) {
     return {
+      "aria-label": I18n.t("share.post", {
+        postNumber: attrs.post_number,
+      }),
+      role: "region",
       "data-post-id": attrs.id,
       "data-topic-id": attrs.topicId,
       "data-user-id": attrs.user_id,

GitHub sha: 6e2ecf40

This commit appears in #13130 which was approved by CvX. It was merged by SamSaffron.