A11Y: Improve the header menu "view all" title. (#12175)
* A11Y: Improve the header menu "view all" title. The title attribute has been used to attempt to provide the link with an accessible name, but the value of the title attribute is “view all” for the link in each of the tabs, and so their purpose is not uniquely identified.
This commit is contained in:
parent
95d3877709
commit
4bc3a64982
|
@ -67,7 +67,12 @@ export default createWidget("link", {
|
||||||
if (attrs.icon) {
|
if (attrs.icon) {
|
||||||
if (attrs["aria-label"]) {
|
if (attrs["aria-label"]) {
|
||||||
let icon = iconNode(attrs.icon);
|
let icon = iconNode(attrs.icon);
|
||||||
icon.properties.attributes["aria-label"] = I18n.t(attrs["aria-label"]);
|
|
||||||
|
icon.properties.attributes["aria-label"] = I18n.t(
|
||||||
|
attrs["aria-label"],
|
||||||
|
attrs.ariaLabelOptions
|
||||||
|
);
|
||||||
|
|
||||||
icon.properties.attributes["role"] = "img";
|
icon.properties.attributes["role"] = "img";
|
||||||
icon.properties.attributes["aria-hidden"] = false;
|
icon.properties.attributes["aria-hidden"] = false;
|
||||||
result.push(icon);
|
result.push(icon);
|
||||||
|
|
|
@ -111,13 +111,17 @@ export default createWidget("quick-access-panel", {
|
||||||
let bottomItems = [];
|
let bottomItems = [];
|
||||||
|
|
||||||
if (!this.hideBottomItems()) {
|
if (!this.hideBottomItems()) {
|
||||||
|
const tab = I18n.t(this.attrs.titleKey).toLowerCase();
|
||||||
|
|
||||||
bottomItems.push(
|
bottomItems.push(
|
||||||
// intentionally a link so it can be ctrl clicked
|
// intentionally a link so it can be ctrl clicked
|
||||||
this.attach("link", {
|
this.attach("link", {
|
||||||
title: "view_all",
|
title: "view_all",
|
||||||
|
titleOptions: { tab },
|
||||||
icon: "chevron-down",
|
icon: "chevron-down",
|
||||||
className: "btn btn-default btn-icon no-text show-all",
|
className: "btn btn-default btn-icon no-text show-all",
|
||||||
"aria-label": "view_all",
|
"aria-label": "view_all",
|
||||||
|
ariaLabelOptions: { tab },
|
||||||
href: this.showAllHref(),
|
href: this.showAllHref(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -13,6 +13,13 @@ const QuickAccess = {
|
||||||
PROFILE: "profile",
|
PROFILE: "profile",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Titles = {
|
||||||
|
bookmarks: "user.bookmarks",
|
||||||
|
messages: "user.private_messages",
|
||||||
|
notifications: "user.notifications",
|
||||||
|
profile: "user.preferences",
|
||||||
|
};
|
||||||
|
|
||||||
let extraGlyphs;
|
let extraGlyphs;
|
||||||
|
|
||||||
export function addUserMenuGlyph(glyph) {
|
export function addUserMenuGlyph(glyph) {
|
||||||
|
@ -51,7 +58,7 @@ createWidget("user-menu-links", {
|
||||||
|
|
||||||
profileGlyph() {
|
profileGlyph() {
|
||||||
return {
|
return {
|
||||||
title: "user.preferences",
|
title: Titles["profile"],
|
||||||
className: "user-preferences-link",
|
className: "user-preferences-link",
|
||||||
icon: "user",
|
icon: "user",
|
||||||
action: UserMenuAction.QUICK_ACCESS,
|
action: UserMenuAction.QUICK_ACCESS,
|
||||||
|
@ -64,7 +71,7 @@ createWidget("user-menu-links", {
|
||||||
|
|
||||||
notificationsGlyph() {
|
notificationsGlyph() {
|
||||||
return {
|
return {
|
||||||
title: "user.notifications",
|
title: Titles["notifications"],
|
||||||
className: "user-notifications-link",
|
className: "user-notifications-link",
|
||||||
icon: "bell",
|
icon: "bell",
|
||||||
action: UserMenuAction.QUICK_ACCESS,
|
action: UserMenuAction.QUICK_ACCESS,
|
||||||
|
@ -77,7 +84,7 @@ createWidget("user-menu-links", {
|
||||||
|
|
||||||
bookmarksGlyph() {
|
bookmarksGlyph() {
|
||||||
return {
|
return {
|
||||||
title: "user.bookmarks",
|
title: Titles["bookmarks"],
|
||||||
action: UserMenuAction.QUICK_ACCESS,
|
action: UserMenuAction.QUICK_ACCESS,
|
||||||
actionParam: QuickAccess.BOOKMARKS,
|
actionParam: QuickAccess.BOOKMARKS,
|
||||||
className: "user-bookmarks-link",
|
className: "user-bookmarks-link",
|
||||||
|
@ -91,7 +98,7 @@ createWidget("user-menu-links", {
|
||||||
|
|
||||||
messagesGlyph() {
|
messagesGlyph() {
|
||||||
return {
|
return {
|
||||||
title: "user.private_messages",
|
title: Titles["messages"],
|
||||||
action: UserMenuAction.QUICK_ACCESS,
|
action: UserMenuAction.QUICK_ACCESS,
|
||||||
actionParam: QuickAccess.MESSAGES,
|
actionParam: QuickAccess.MESSAGES,
|
||||||
className: "user-pms-link",
|
className: "user-pms-link",
|
||||||
|
@ -126,6 +133,8 @@ createWidget("user-menu-links", {
|
||||||
}
|
}
|
||||||
if (g) {
|
if (g) {
|
||||||
const structuredGlyph = this._structureAsTab(g);
|
const structuredGlyph = this._structureAsTab(g);
|
||||||
|
Titles[structuredGlyph.actionParam] =
|
||||||
|
structuredGlyph.title || structuredGlyph.label;
|
||||||
glyphs.push(structuredGlyph);
|
glyphs.push(structuredGlyph);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -188,6 +197,7 @@ export default createWidget("user-menu", {
|
||||||
defaultState() {
|
defaultState() {
|
||||||
return {
|
return {
|
||||||
currentQuickAccess: QuickAccess.NOTIFICATIONS,
|
currentQuickAccess: QuickAccess.NOTIFICATIONS,
|
||||||
|
titleKey: Titles["notifications"],
|
||||||
hasUnread: false,
|
hasUnread: false,
|
||||||
markUnread: null,
|
markUnread: null,
|
||||||
};
|
};
|
||||||
|
@ -195,14 +205,14 @@ export default createWidget("user-menu", {
|
||||||
|
|
||||||
panelContents() {
|
panelContents() {
|
||||||
const path = this.currentUser.get("path");
|
const path = this.currentUser.get("path");
|
||||||
const { currentQuickAccess } = this.state;
|
const { currentQuickAccess, titleKey } = this.state;
|
||||||
|
|
||||||
const result = [
|
const result = [
|
||||||
this.attach("user-menu-links", {
|
this.attach("user-menu-links", {
|
||||||
path,
|
path,
|
||||||
currentQuickAccess,
|
currentQuickAccess,
|
||||||
}),
|
}),
|
||||||
this.quickAccessPanel(path),
|
this.quickAccessPanel(path, titleKey),
|
||||||
];
|
];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -255,15 +265,17 @@ export default createWidget("user-menu", {
|
||||||
quickAccess(type) {
|
quickAccess(type) {
|
||||||
if (this.state.currentQuickAccess !== type) {
|
if (this.state.currentQuickAccess !== type) {
|
||||||
this.state.currentQuickAccess = type;
|
this.state.currentQuickAccess = type;
|
||||||
|
this.state.titleKey = Titles[type];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
quickAccessPanel(path) {
|
quickAccessPanel(path, titleKey) {
|
||||||
const { showLogoutButton } = this.settings;
|
const { showLogoutButton } = this.settings;
|
||||||
// This deliberately does NOT fallback to a default quick access panel.
|
// This deliberately does NOT fallback to a default quick access panel.
|
||||||
return this.attach(`quick-access-${this.state.currentQuickAccess}`, {
|
return this.attach(`quick-access-${this.state.currentQuickAccess}`, {
|
||||||
path,
|
path,
|
||||||
showLogoutButton,
|
showLogoutButton,
|
||||||
|
titleKey,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -2259,7 +2259,7 @@ en:
|
||||||
go_back: "go back"
|
go_back: "go back"
|
||||||
not_logged_in_user: "user page with summary of current activity and preferences"
|
not_logged_in_user: "user page with summary of current activity and preferences"
|
||||||
current_user: "go to your user page"
|
current_user: "go to your user page"
|
||||||
view_all: "view all"
|
view_all: "view all %{tab}"
|
||||||
|
|
||||||
topics:
|
topics:
|
||||||
new_messages_marker: "last visit"
|
new_messages_marker: "last visit"
|
||||||
|
|
Loading…
Reference in New Issue