Skip to content

A platform for community discussion. Free, open, simple.

A11Y: Improve "my posts" sidebar link title (#19132)

Kris69e55a0e1ce9
diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js
index 01544b54d9d..82fceb4bd0e 100644
--- a/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js
+++ b/app/assets/javascripts/discourse/app/lib/sidebar/user/community-section/my-posts-section-link.js
@@ -47,7 +47,11 @@ export default class MyPostsSectionLink extends BaseSectionLink {
}
get title() {
- return I18n.t("sidebar.sections.community.links.my_posts.title");
+ if (this._hasDraft) {
+ return I18n.t("sidebar.sections.community.links.my_posts.title_drafts");
+ } else {
+ return I18n.t("sidebar.sections.community.links.my_posts.title");
+ }
}
get text() {
diff --git a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
index 0b2ca1c1da3..47c505d2f37 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/sidebar-user-community-section-test.js
@@ -564,6 +564,26 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
);
});
+ test("my posts title changes when drafts are present", async function (assert) {
+ await visit("/");
+
+ assert.strictEqual(
+ query(".sidebar-section-link-my-posts").title,
+ I18n.t("sidebar.sections.community.links.my_posts.title"),
+ "displays the default title when no drafts are present"
+ );
+
+ await publishToMessageBus(`/user-drafts/${loggedInUser().id}`, {
+ draft_count: 1,
+ });
+
+ assert.strictEqual(
+ query(".sidebar-section-link-my-posts").title,
+ I18n.t("sidebar.sections.community.links.my_posts.title_drafts"),
+ "displays the draft title when drafts are present"
+ );
+ });
+
test("visiting top route", async function (assert) {
await visit("/top");
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index a04315378a9..d23ec802ea3 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4248,7 +4248,8 @@ en:
title: "All users"
my_posts:
content: "My Posts"
- title: "My posts"
+ title: "My recent topic activity"
+ title_drafts: "My unposted drafts"
draft_count:
one: "%{count} draft"
other: "%{count} drafts"