A11Y: do not default to label for aria-label (#14258)

A11Y: do not default to label for aria-label (#14258)

diff --git a/app/assets/javascripts/discourse/app/components/d-button.js b/app/assets/javascripts/discourse/app/components/d-button.js
index 73d6350..a584851 100644
--- a/app/assets/javascripts/discourse/app/components/d-button.js
+++ b/app/assets/javascripts/discourse/app/components/d-button.js
@@ -85,15 +85,14 @@ export default Component.extend({
     return translatedLabel;
   },
 
-  @discourseComputed("ariaLabel", "translatedAriaLabel", "computedLabel")
-  computedAriaLabel(ariaLabel, translatedAriaLabel, computedLabel) {
+  @discourseComputed("ariaLabel", "translatedAriaLabel")
+  computedAriaLabel(ariaLabel, translatedAriaLabel) {
     if (ariaLabel) {
       return I18n.t(ariaLabel);
     }
     if (translatedAriaLabel) {
       return translatedAriaLabel;
     }
-    return computedLabel;
   },
 
   @discourseComputed("ariaExpanded")
diff --git a/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js b/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js
index a11b760..89fc587 100644
--- a/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js
+++ b/app/assets/javascripts/discourse/app/controllers/topic-bulk-actions.js
@@ -99,7 +99,7 @@ addBulkButton("removeTags", "remove_tags", {
 });
 addBulkButton("deleteTopics", "delete", {
   icon: "trash-alt",
-  class: "btn-danger",
+  class: "btn-danger delete-topics",
   buttonVisible: function () {
     return this.currentUser.staff;
   },
diff --git a/app/assets/javascripts/discourse/app/controllers/user.js b/app/assets/javascripts/discourse/app/controllers/user.js
index 34d032e..b1083d1 100644
--- a/app/assets/javascripts/discourse/app/controllers/user.js
+++ b/app/assets/javascripts/discourse/app/controllers/user.js
@@ -61,6 +61,9 @@ export default Controller.extend(CanCheckEmails, {
       isExpanded: !this.collapsedInfo,
       icon: this.collapsedInfo ? "angle-double-down" : "angle-double-up",
       label: this.collapsedInfo ? "expand_profile" : "collapse_profile",
+      ariaLabel: this.collapsedInfo
+        ? "user.sr_expand_profile"
+        : "user.sr_collapse_profile",
       action: this.collapsedInfo ? "expandProfile" : "collapseProfile",
     };
   }),
diff --git a/app/assets/javascripts/discourse/app/templates/modal/reject-reason-reviewable.hbs b/app/assets/javascripts/discourse/app/templates/modal/reject-reason-reviewable.hbs
index ca82a2f..e43f90c 100644
--- a/app/assets/javascripts/discourse/app/templates/modal/reject-reason-reviewable.hbs
+++ b/app/assets/javascripts/discourse/app/templates/modal/reject-reason-reviewable.hbs
@@ -13,5 +13,5 @@
 
 <div class="modal-footer">
   {{d-button icon="trash-alt" class="btn-danger" action=(action "perform") label="admin.user.delete"}}
-  {{d-button action=(route-action "closeModal") label="cancel"}}
+  {{d-button action=(route-action "closeModal") label="cancel" class="cancel"}}
 </div>
diff --git a/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs b/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs
index 7aaf380..cbdac56 100644
--- a/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs
+++ b/app/assets/javascripts/discourse/app/templates/modal/share-topic.hbs
@@ -19,7 +19,7 @@
         {{/each}}
 
         {{d-button
-          class="btn-default"
+          class="btn-default notify"
           label="topic.share.notify_users.title"
           icon="hand-point-right"
           action=(action "toggleNotifyUsers")
@@ -27,7 +27,7 @@
 
         {{#if allowInvites}}
           {{d-button
-            class="btn-default"
+            class="btn-default invite"
             label="topic.share.invite_users"
             icon="user-plus"
             action=(action "inviteUsers")
diff --git a/app/assets/javascripts/discourse/app/templates/user.hbs b/app/assets/javascripts/discourse/app/templates/user.hbs
index a714cc8..fe532fd 100644
--- a/app/assets/javascripts/discourse/app/templates/user.hbs
+++ b/app/assets/javascripts/discourse/app/templates/user.hbs
@@ -82,6 +82,7 @@
                 <li>
                   {{d-button
                     ariaExpanded=collapsedInfoState.isExpanded
+                    ariaLabel=collapsedInfoState.ariaLabel
                     ariaControls="collapsed-info-panel"
                     class="btn-default"
                     label=(concat "user." collapsedInfoState.label)
diff --git a/app/assets/javascripts/discourse/tests/acceptance/review-test.js b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
index b5a0448..e4711c9 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/review-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/review-test.js
@@ -59,7 +59,7 @@ acceptance("Review", function (needs) {
       "it opens reject reason modal when user is rejected"
     );
 
-    await click(".modal-footer button[aria-label='cancel']");
+    await click(".modal-footer .cancel");
     await reviewableActionDropdown.expand();
     await reviewableActionDropdown.selectRowByValue("reject_user_block");
 
diff --git a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js
index fbec739..0b952d6 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/share-topic-test.js
@@ -31,14 +31,13 @@ acceptance("Share and Invite modal", function (needs) {
     );
 
     assert.ok(count("button[class*='share-']") > 1, "it shows social sources");
-
     assert.ok(
-      exists(".btn[aria-label='Notify']"),
+      exists(".link-share-actions .notify"),
       "it shows the notify button"
     );
 
     assert.ok(
-      exists(".btn[aria-label='Invite']"),
+      exists(".link-share-actions .invite"),
       "it shows the invite button"
     );
   });
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js
index c285eda..79d8989 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-bulk-actions-test.js
@@ -114,7 +114,7 @@ acceptance("Topic - Bulk Actions", function (needs) {
     await click(queryAll("input.bulk-select")[1]);
 
     await click(".bulk-select-btn");
-    await click(".modal-body button[aria-label='Delete Topics']");
+    await click(".modal-body .delete-topics");
 
     assert.ok(
       invisible(".topic-bulk-actions-modal"),
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 846e751..b3e5372 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1040,7 +1040,9 @@ en:
       use_current_timezone: "Use Current Timezone"
       profile_hidden: "This user's public profile is hidden."
       expand_profile: "Expand"
+      sr_expand_profile: "Expand profile details"
       collapse_profile: "Collapse"
+      sr_collapse_profile: "Collapse profile details"
       bookmarks: "Bookmarks"
       bio: "About me"
       timezone: "Timezone"

GitHub sha: d51d94f771cc5912374a24c030f6965fdacbcb7a

This commit appears in #14258 which was approved by eviltrout. It was merged by jjaffeux.