mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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) {
|
keyDown(e) {
|
||||||
if (e.which === 27 /* escape */) {
|
if (e.key === "Escape") {
|
||||||
this.sendWidgetAction("toggleSearchMenu");
|
this.sendWidgetAction("toggleSearchMenu");
|
||||||
|
document.querySelector("#search-button").focus();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -450,6 +450,11 @@ acceptance("Search - Authenticated", function (needs) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
await triggerKeyEvent(".search-menu", "keydown", "Escape");
|
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");
|
assert.ok(!exists(".search-menu:visible"), "Esc removes search dropdown");
|
||||||
|
|
||||||
await click("#search-button");
|
await click("#search-button");
|
||||||
|
Loading…
Reference in New Issue
Block a user