Skip to content

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

A11Y: add `aria-hidden="true"` wrapper around zero width space character in buttons (#31544)

Kris7fc946af4cfb
diff --git a/app/assets/javascripts/admin/addon/components/admin-watched-word.gjs b/app/assets/javascripts/admin/addon/components/admin-watched-word.gjs
index 4a2c61e3801..b74be4188bc 100644
--- a/app/assets/javascripts/admin/addon/components/admin-watched-word.gjs
+++ b/app/assets/javascripts/admin/addon/components/admin-watched-word.gjs
@@ -34,7 +34,7 @@ export default class AdminWatchedWord extends Component {
class="btn-transparent delete-word-record"
/>
- <span>{{@word.word}}</span>
+ <span class="watched-word__content">{{@word.word}}</span>
{{#if (or (eq @actionKey "replace") (eq @actionKey "link"))}}
&rarr;
diff --git a/app/assets/javascripts/discourse/app/components/d-button.gjs b/app/assets/javascripts/discourse/app/components/d-button.gjs
index a3861139257..6a895635fcc 100644
--- a/app/assets/javascripts/discourse/app/components/d-button.gjs
+++ b/app/assets/javascripts/discourse/app/components/d-button.gjs
@@ -231,8 +231,10 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView {
{{~/if~}}
</span>
{{~else if (or @icon @isLoading)~}}
- &#8203;
- {{! Zero-width space character, so icon-only button height = regular button height }}
+ <span aria-hidden="true">
+ &#8203;
+ {{! Zero-width space character, so icon-only button height = regular button height }}
+ </span>
{{~/if~}}
{{yield}}
diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js
index 8352cbed86b..c06750b1e09 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-watched-words-test.js
@@ -95,7 +95,7 @@ acceptance("Admin - Watched Words", function (needs) {
await click(".watched-word-form .btn-primary");
assert
- .dom(".watched-words-list .watched-word span:first-of-type")
+ .dom(".watched-words-list .watched-word .watched-word__content")
.hasText("Discourse");
assert
.dom(".watched-words-list .watched-word .case-sensitive")
@@ -108,7 +108,7 @@ acceptance("Admin - Watched Words", function (needs) {
await click(".watched-word-form .btn-primary");
assert
- .dom(".watched-words-list .watched-word span:first-of-type")
+ .dom(".watched-words-list .watched-word .watched-word__content")
.hasText("discourse");
assert
.dom(".watched-words-list .watched-word .case-sensitive")