From 8417c9829ebfcb4f3adfb95fdb8dbff510e653d1 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 26 Jan 2021 16:33:15 +0100 Subject: [PATCH] A11Y: hamburger menu aria-{expanded,haspopup} and user title (#11852) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User title in the current-user header-dropdown was sometimes `title="null"` if user doesn’t have a name. This is fixed as part of this commit to improve accessibility of this part of the UI. --- app/assets/javascripts/discourse/app/widgets/header.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/app/widgets/header.js b/app/assets/javascripts/discourse/app/widgets/header.js index f8747fa552..e581b7d752 100644 --- a/app/assets/javascripts/discourse/app/widgets/header.js +++ b/app/assets/javascripts/discourse/app/widgets/header.js @@ -146,8 +146,10 @@ createWidget( "a.icon", { attributes: { - href: attrs.user.get("path"), - title: attrs.user.get("name"), + "aria-haspopup": true, + "aria-expanded": attrs.active, + href: attrs.user.path, + title: attrs.user.name || attrs.user.username, "data-auto-route": true, }, }, @@ -177,6 +179,8 @@ createWidget( "a.icon.btn-flat", { attributes: { + "aria-expanded": attrs.active, + "aria-haspopup": true, href: attrs.href, "data-auto-route": true, title, @@ -441,7 +445,7 @@ export default createWidget("header", { if (this.site.mobileView) { const searchService = this.register.lookup("search-service:main"); const context = searchService.get("searchContext"); - var params = ""; + let params = ""; if (context) { params = `?context=${context.type}&context_id=${context.id}&skip_context=${this.state.skipSearchContext}`;