A platform for community discussion. Free, open, simple.
A11Y: read who liked/read a post when count clicked (#31549)
Kris5312550bf984
diff --git a/app/assets/javascripts/discourse/app/components/post/menu.gjs b/app/assets/javascripts/discourse/app/components/post/menu.gjsindex 5c80ae3ecbc..39827b24fe9 100644--- a/app/assets/javascripts/discourse/app/components/post/menu.gjs+++ b/app/assets/javascripts/discourse/app/components/post/menu.gjs@@ -631,46 +631,38 @@ export default class PostMenu extends Component {{{/each}}</div></nav>- {{#if this.isWhoReadVisible}}- <SmallUserList- class="who-read"- @addSelf={{false}}- @ariaLabel={{i18n- "post.actions.people.sr_post_readers_list_description"- }}- @count={{if- this.remainingReaders- this.remainingReaders- this.totalReaders- }}- @description={{if- this.remainingReaders- "post.actions.people.read_capped"- "post.actions.people.read"- }}- @users={{this.readers}}- />- {{/if}}- {{#if this.isWhoLikedVisible}}- <SmallUserList- class="who-liked"- @addSelf={{and @post.liked (eq this.remainingLikedUsers 0)}}- @ariaLabel={{i18n- "post.actions.people.sr_post_likers_list_description"- }}- @count={{if- this.remainingLikedUsers- this.remainingLikedUsers- this.totalLikedUsers- }}- @description={{if- this.remainingLikedUsers- "post.actions.people.like_capped"- "post.actions.people.like"- }}- @users={{this.likedUsers}}- />- {{/if}}+ <SmallUserList+ class="who-read"+ @addSelf={{false}}+ @isVisible={{this.isWhoReadVisible}}+ @count={{if+ this.remainingReaders+ this.remainingReaders+ this.totalReaders+ }}+ @description={{if+ this.remainingReaders+ "post.actions.people.read_capped"+ "post.actions.people.read"+ }}+ @users={{this.readers}}+ />+ <SmallUserList+ class="who-liked"+ @addSelf={{and @post.liked (eq this.remainingLikedUsers 0)}}+ @isVisible={{this.isWhoLikedVisible}}+ @count={{if+ this.remainingLikedUsers+ this.remainingLikedUsers+ this.totalLikedUsers+ }}+ @description={{if+ this.remainingLikedUsers+ "post.actions.people.like_capped"+ "post.actions.people.like"+ }}+ @users={{this.likedUsers}}+ />{{#if(this.showMoreButton.shouldRender(hash post=this.post state=this.state)diff --git a/app/assets/javascripts/discourse/app/components/small-user-list.gjs b/app/assets/javascripts/discourse/app/components/small-user-list.gjsindex c228907d36c..a629a377bfc 100644--- a/app/assets/javascripts/discourse/app/components/small-user-list.gjs+++ b/app/assets/javascripts/discourse/app/components/small-user-list.gjs@@ -42,15 +42,23 @@ export default class SmallUserList extends Component {}}+ get shouldShow() {+ return this.users && this.args.isVisible;+ }+<template>- {{#if this.users}}- <PluginOutlet @name="small-user-list-internal" @outletArgs={{this.args}}>- <div class="clearfix small-user-list" ...attributes>- <span- class="small-user-list-content"- aria-label={{@ariaLabel}}- role="list"- >+ <PluginOutlet @name="small-user-list-internal" @outletArgs={{this.args}}>+ <div+ class="small-user-list {{if this.shouldShow '--expanded'}}"+ ...attributes+ >+ <span+ class="small-user-list-content"+ role="list"+ aria-live="polite"+ aria-atomic="true"+ >+ {{#if this.shouldShow}}{{#each this.users key="username" as |user|}}{{#if user.unknown}}<div@@ -74,19 +82,19 @@ export default class SmallUserList extends Component {{{#if @description}}{{#if this.postUrl}}<a href={{this.postUrl}}>- <span aria-hidden="true" class="list-description">+ <span class="list-description">{{i18n @description count=@count}}</span></a>{{else}}- <span aria-hidden="true" class="list-description">+ <span class="list-description">{{i18n @description count=@count}}</span>{{/if}}{{/if}}- </span>- </div>- </PluginOutlet>- {{/if}}+ {{/if}}+ </span>+ </div>+ </PluginOutlet></template>}diff --git a/app/assets/javascripts/discourse/app/widgets/actions-summary.js b/app/assets/javascripts/discourse/app/widgets/actions-summary.jsindex 0020467f60c..50e15241435 100644--- a/app/assets/javascripts/discourse/app/widgets/actions-summary.js+++ b/app/assets/javascripts/discourse/app/widgets/actions-summary.js@@ -12,7 +12,8 @@ registerWidgetShim(@users={{@data.users}}@addSelf={{@data.addSelf}}@count={{@data.count}}- @description={{@data.description}}/>`+ @description={{@data.description}}+ @isVisible={{@data.isVisible}}/>`);registerWidgetShim(diff --git a/app/assets/javascripts/discourse/app/widgets/post-menu.js b/app/assets/javascripts/discourse/app/widgets/post-menu.jsindex a4714b3ddb6..9d0e1e381b2 100644--- a/app/assets/javascripts/discourse/app/widgets/post-menu.js+++ b/app/assets/javascripts/discourse/app/widgets/post-menu.js@@ -783,9 +783,7 @@ export default createWidget("post-menu", {listClassName: "who-read",description,count,- ariaLabel: i18n(- "post.actions.people.sr_post_readers_list_description"- ),+ isVisible: true,}));}@@ -805,9 +803,7 @@ export default createWidget("post-menu", {listClassName: "who-liked",description,count,- ariaLabel: i18n(- "post.actions.people.sr_post_likers_list_description"- ),+ isVisible: true,}));}diff --git a/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.js b/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.jsindex cc4355726a8..419fa60dfff 100644--- a/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/post-controls-test.js@@ -17,13 +17,6 @@ import { i18n } from "discourse-i18n";assert.dom("#post_2 button.like-count").hasAria("pressed", "false", "show likes button isn't pressed");- assert- .dom("#post_2 button.like-count")- .hasAria(- "label",- i18n("post.sr_post_like_count_button", { count: 4 }),- "show likes button has aria-label"- );await click("#post_2 button.like-count");assert@@ -33,16 +26,6 @@ import { i18n } from "discourse-i18n";assert.dom("#post_2 .small-user-list.who-liked .small-user-list-content").hasAttribute("role", "list", "likes container has list role");- assert- .dom("#post_2 .small-user-list.who-liked .small-user-list-content")- .hasAria(- "label",- i18n("post.actions.people.sr_post_likers_list_description"),- "likes container has aria-label"- );- assert- .dom("#post_2 .small-user-list.who-liked .list-description")- .hasAria("hidden", "true", "list description is aria-hidden");assert.dom("#post_2 .small-user-list.who-liked a.trigger-user-card")diff --git a/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.js b/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.jsindex f642da5fc28..90437335aad 100644--- a/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.js+++ b/app/assets/javascripts/discourse/tests/integration/components/widgets/small-user-list-test.js@@ -12,6 +12,7 @@ module("Integration | Component | Widget | small-user-list", function (hooks) {{ id: 456, username: "eviltrout" },{ id: 457, username: "someone", unknown: true },],+ isVisible: true,});await render(diff --git a/app/assets/stylesheets/desktop/topic-post.scss b/app/assets/stylesheets/desktop/topic-post.scssindex 32203282175..1fdde9ebb3c 100644--- a/app/assets/stylesheets/desktop/topic-post.scss+++ b/app/assets/stylesheets/desktop/topic-post.scss@@ -671,10 +671,13 @@ a.attachment::before {.who-liked,.who-read {- margin-top: 20px;margin-bottom: 0;width: 100%;text-align: right;++ &.--expanded {+ margin-top: 1.25em;+ }}span.highlighted {diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 9242b0de417..877f31f2861 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -3853,11 +3853,11 @@ en:other: "you and %{count} other people liked this post"sr_post_like_count_button:- one: "%{count} person liked this post. Click to view"- other: "%{count} people liked this post. Click to view"+ one: "%{count} person liked this post."+ other: "%{count} people liked this post."sr_post_read_count_button:- one: "%{count} person read this post. Click to view"- other: "%{count} people read this post. Click to view"+ one: "%{count} person read this post."+ other: "%{count} people read this post."filtered_replies_hint:one: "View this post and its reply"other: "View this post and its %{count} replies"@@ -3984,8 +3984,6 @@ en:read_capped:one: "and %{count} other read this"other: "and %{count} others read this"- sr_post_likers_list_description: "users who liked this post"- sr_post_readers_list_description: "users who read this post"by_you:off_topic: "You flagged this as off-topic"spam: "You flagged this as spam"