A11Y: hamburger menu aria-{expanded,haspopup} and user title (#11852)

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.
This commit is contained in:
Joffrey JAFFEUX 2021-01-26 16:33:15 +01:00 committed by GitHub
parent 3bbe87f229
commit 8417c9829e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}`;