A11Y: Keyboard access for /u table headings (#17041)

This commit is contained in:
Penar Musaraj 2022-06-08 17:54:31 +00:00 committed by GitHub
parent 852a2f1727
commit fd2dbdccdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -31,6 +31,11 @@ export default Component.extend({
click() {
this.toggleProperties();
},
keyPress(e) {
if (e.which === 13) {
this.toggleProperties();
}
},
didReceiveAttrs() {
this._super(...arguments);
if (!this.automatic && !this.translated) {

View File

@ -1,4 +1,8 @@
<span class="header-contents" id={{id}}>
<span
class="header-contents"
id={{id}}
role="button"
tabindex="0">
{{directory-table-header-title field=field labelKey=labelKey icon=icon translated=translated}}
{{chevronIcon}}
</span>

View File

@ -5,7 +5,7 @@ import {
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import { test } from "qunit";
import { click, visit } from "@ember/test-helpers";
import { click, triggerKeyEvent, visit } from "@ember/test-helpers";
acceptance("User Directory", function () {
test("Visit Page", async function (assert) {
@ -43,6 +43,20 @@ acceptance("User Directory", function () {
"Blue"
);
});
test("Can sort table via keyboard", async function (assert) {
await visit("/u");
const secondHeading =
".users-directory table th:nth-child(2) .header-contents";
await triggerKeyEvent(secondHeading, "keypress", 13);
assert.ok(
query(`${secondHeading} .d-icon-chevron-up`),
"list has been sorted"
);
});
});
acceptance("User directory - Editing columns", function (needs) {