Skip to content

Commit 24c0b9b

Browse files
committed
Switch dark / light mode on ESC key
There is an interaction between the usage if the ESC key in the search box and the the possibility to toggle. By not propagating the ESC key lands where it is intended.
1 parent d1eeb21 commit 24c0b9b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Diff for: templates/html/darkmode_toggle.js

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class DarkModeToggle extends HTMLElement {
102102
})
103103
$(document).keyup(function(e) {
104104
if (e.key === "Escape") { // escape key maps to keycode `27`
105+
e.stopPropagation();
105106
DarkModeToggle.userPreference = !DarkModeToggle.userPreference
106107
}
107108
})

Diff for: templates/html/search.js

+4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ function SearchBox(name, resultsPath, extension)
195195
}
196196
else if (e.keyCode==27) // Escape out of the search field
197197
{
198+
e.stopPropagation();
198199
this.DOMSearchField().blur();
199200
this.DOMPopupSearchResultsWindow().style.display = 'none';
200201
this.DOMSearchClose().style.display = 'none';
@@ -289,6 +290,7 @@ function SearchBox(name, resultsPath, extension)
289290
}
290291
else if (e.keyCode==13 || e.keyCode==27)
291292
{
293+
e.stopPropagation();
292294
this.OnSelectItem(this.searchIndex);
293295
this.CloseSelectionWindow();
294296
this.DOMSearchField().focus();
@@ -670,6 +672,7 @@ function SearchResults(name)
670672
}
671673
else if (this.lastKey==27) // Escape
672674
{
675+
e.stopPropagation();
673676
searchBox.CloseResultsWindow();
674677
document.getElementById("MSearchField").focus();
675678
}
@@ -713,6 +716,7 @@ function SearchResults(name)
713716
}
714717
else if (this.lastKey==27) // Escape
715718
{
719+
e.stopPropagation();
716720
searchBox.CloseResultsWindow();
717721
document.getElementById("MSearchField").focus();
718722
}

0 commit comments

Comments
 (0)