A11Y: Return focus to header search button upon escape of search (#18656)
This commit is contained in:
parent
799fa8d6f9
commit
a8af510636
|
@ -356,8 +356,9 @@ export default createWidget("search-menu", {
|
|||
},
|
||||
|
||||
keyDown(e) {
|
||||
if (e.which === 27 /* escape */) {
|
||||
if (e.key === "Escape") {
|
||||
this.sendWidgetAction("toggleSearchMenu");
|
||||
document.querySelector("#search-button").focus();
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -450,6 +450,11 @@ acceptance("Search - Authenticated", function (needs) {
|
|||
);
|
||||
|
||||
await triggerKeyEvent(".search-menu", "keydown", "Escape");
|
||||
assert.strictEqual(
|
||||
document.activeElement,
|
||||
query("#search-button"),
|
||||
"Escaping search returns focus to search button"
|
||||
);
|
||||
assert.ok(!exists(".search-menu:visible"), "Esc removes search dropdown");
|
||||
|
||||
await click("#search-button");
|
||||
|
|
Loading…
Reference in New Issue