Unverified Commit 1af77eaf authored by lauriii's avatar lauriii
Browse files

Issue #3209125 by tushar_sachdeva, aaron.ferris, kishor_kolekar, paulocs,...

Issue #3209125 by tushar_sachdeva, aaron.ferris, kishor_kolekar, paulocs, KapilV, Abhijith S, Sakthivel M, mherchel: Olivero: Desktop search form should close when ESC key is pressed
parent 3296fcb5
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
Drupal.olivero.toggleSearchVisibility = toggleSearchVisibility; Drupal.olivero.toggleSearchVisibility = toggleSearchVisibility;
document.addEventListener('keyup', (e) => {
if (e.key === 'Escape' || e.key === 'Esc') {
toggleSearchVisibility(false);
}
});
document.addEventListener('click', (e) => { document.addEventListener('click', (e) => {
if ( if (
e.target.matches( e.target.matches(
......
...@@ -38,6 +38,11 @@ ...@@ -38,6 +38,11 @@
} }
Drupal.olivero.toggleSearchVisibility = toggleSearchVisibility; Drupal.olivero.toggleSearchVisibility = toggleSearchVisibility;
document.addEventListener('keyup', function (e) {
if (e.key === 'Escape' || e.key === 'Esc') {
toggleSearchVisibility(false);
}
});
document.addEventListener('click', function (e) { document.addEventListener('click', function (e) {
if (e.target.matches('.header-nav__search-button, .header-nav__search-button *')) { if (e.target.matches('.header-nav__search-button, .header-nav__search-button *')) {
toggleSearchVisibility(!searchIsVisible()); toggleSearchVisibility(!searchIsVisible());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment