mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
A11Y: Improve the quick access menu accessibility. (#11757)
- The icon for the “view all” controls in the panels have no accessible alternative. - Because the “Log Out” and "Do Not Disturb" elements in the preferences tab are an <a> element without an href attribute, it is not keyboard focusable and therefore not keyboard focusable. Use a button element instead.
This commit is contained in:
parent
da2ed566e3
commit
48f06e56f2
@ -12,7 +12,7 @@ export default createWidget("do-not-disturb", {
|
|||||||
html() {
|
html() {
|
||||||
if (this.currentUser.isInDoNotDisturb()) {
|
if (this.currentUser.isInDoNotDisturb()) {
|
||||||
return [
|
return [
|
||||||
h("a.do-not-disturb-inner-container", [
|
h("button.btn-flat.do-not-disturb-inner-container", [
|
||||||
iconNode("toggle-on"),
|
iconNode("toggle-on"),
|
||||||
h("span.do-not-disturb-label", [
|
h("span.do-not-disturb-label", [
|
||||||
h("span", I18n.t("do_not_disturb.label")),
|
h("span", I18n.t("do_not_disturb.label")),
|
||||||
@ -22,7 +22,7 @@ export default createWidget("do-not-disturb", {
|
|||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
return [
|
return [
|
||||||
h("a.do-not-disturb-inner-container", [
|
h("button.btn-flat.do-not-disturb-inner-container", [
|
||||||
iconNode("toggle-off"),
|
iconNode("toggle-off"),
|
||||||
h("span.do-not-disturb-label", I18n.t("do_not_disturb.label")),
|
h("span.do-not-disturb-label", I18n.t("do_not_disturb.label")),
|
||||||
]),
|
]),
|
||||||
|
@ -19,7 +19,7 @@ import { iconNode } from "discourse-common/lib/icon-library";
|
|||||||
* read
|
* read
|
||||||
* username
|
* username
|
||||||
*/
|
*/
|
||||||
createWidget("quick-access-item", {
|
export default createWidget("quick-access-item", {
|
||||||
tagName: "li",
|
tagName: "li",
|
||||||
|
|
||||||
buildClasses(attrs) {
|
buildClasses(attrs) {
|
||||||
|
@ -108,6 +108,7 @@ export default createWidget("quick-access-panel", {
|
|||||||
title: "view_all",
|
title: "view_all",
|
||||||
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",
|
||||||
href: this.showAllHref(),
|
href: this.showAllHref(),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
import QuickAccessItem from "discourse/widgets/quick-access-item";
|
||||||
import QuickAccessPanel from "discourse/widgets/quick-access-panel";
|
import QuickAccessPanel from "discourse/widgets/quick-access-panel";
|
||||||
import { createWidgetFrom } from "discourse/widgets/widget";
|
import { createWidgetFrom } from "discourse/widgets/widget";
|
||||||
|
|
||||||
@ -9,6 +10,19 @@ export function addQuickAccessProfileItem(item) {
|
|||||||
_extraItems.push(item);
|
_extraItems.push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createWidgetFrom(QuickAccessItem, "logout-item", {
|
||||||
|
tagName: "li.logout",
|
||||||
|
|
||||||
|
html() {
|
||||||
|
return this.attach("flat-button", {
|
||||||
|
action: "logout",
|
||||||
|
content: I18n.t("user.log_out"),
|
||||||
|
icon: "sign-out-alt",
|
||||||
|
label: "user.log_out",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
||||||
tagName: "div.quick-access-panel.quick-access-profile",
|
tagName: "div.quick-access-panel.quick-access-profile",
|
||||||
|
|
||||||
@ -36,7 +50,7 @@ createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
|||||||
items = items.concat(_extraItems);
|
items = items.concat(_extraItems);
|
||||||
|
|
||||||
if (this.attrs.showLogoutButton) {
|
if (this.attrs.showLogoutButton) {
|
||||||
items.push(this._logOutButton());
|
items.push({ widget: "logout-item" });
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
},
|
},
|
||||||
@ -103,15 +117,6 @@ createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_logOutButton() {
|
|
||||||
return {
|
|
||||||
action: "logout",
|
|
||||||
className: "logout",
|
|
||||||
content: I18n.t("user.log_out"),
|
|
||||||
icon: "sign-out-alt",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
_showToggleAnonymousButton() {
|
_showToggleAnonymousButton() {
|
||||||
return (
|
return (
|
||||||
(this.siteSettings.allow_anonymous_posting &&
|
(this.siteSettings.allow_anonymous_posting &&
|
||||||
|
@ -94,9 +94,10 @@ discourseModule("Integration | Component | Widget | user-menu", function (
|
|||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
await click(".user-preferences-link");
|
await click(".user-preferences-link");
|
||||||
|
|
||||||
assert.ok(queryAll(".logout").length);
|
assert.ok(queryAll(".logout").length);
|
||||||
|
|
||||||
await click(".logout");
|
await click(".logout button");
|
||||||
assert.ok(this.loggedOut);
|
assert.ok(this.loggedOut);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -283,6 +283,10 @@
|
|||||||
|
|
||||||
a {
|
a {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
a,
|
||||||
|
button {
|
||||||
padding: 0.25em 0.5em;
|
padding: 0.25em 0.5em;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
@ -396,7 +400,8 @@ div.menu-links-header {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a,
|
||||||
|
button {
|
||||||
// This is to make sure active and inactive tab icons have the same
|
// This is to make sure active and inactive tab icons have the same
|
||||||
// size. `box-sizing` does not work and I have no idea why.
|
// size. `box-sizing` does not work and I have no idea why.
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
.user-menu .quick-access-panel.quick-access-profile li:not(.show-all) {
|
.user-menu .quick-access-panel.quick-access-profile li:not(.show-all) {
|
||||||
border-bottom: 1px solid var(--primary-low);
|
border-bottom: 1px solid var(--primary-low);
|
||||||
|
|
||||||
a {
|
a,
|
||||||
|
button {
|
||||||
// accounts for menu "ears" 4px + border 1px
|
// accounts for menu "ears" 4px + border 1px
|
||||||
padding: 0.75em calc(0.5em + 4px + 1px);
|
padding: 0.75em calc(0.5em + 4px + 1px);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user