Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx==4.4.0
sphinx==4.5.0
sphinx-prompt==1.5.0
sphinx-tabs==3.2.0
sphinx-rtd-theme==1.0.0
Expand Down
18 changes: 9 additions & 9 deletions sphinx_search/static/js/rtd_sphinx_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const debounce = (func, wait) => {

/**
* Wrapper around underscorejs's template function.
*
*
* This is to make it work with new and old versions.
*/
const render_template = (template, data) => {
Expand Down Expand Up @@ -788,6 +788,14 @@ window.addEventListener("DOMContentLoaded", () => {
form.submit();
}
}

// close the search modal if the user pressed
// Escape button
if (e.keyCode === 27) {
// Avoid triggering Sphinx's 'hideSearchWords' shortcut.
e.stopPropagation();
removeSearchModal();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but now the modal isn't closed if the panel lost the focus (and hideSearchWords is triggered :/), was able to reproduce by clicking on the "white area" of the modal, but clicking on the search box gains the focus and escape works again.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you'll need to add an event listener for something other than the input box. This key code event is only on the search_outer_input element, where you likely also want to listen on search_outer.

});

search_outer_wrapper.addEventListener("click", e => {
Expand All @@ -805,14 +813,6 @@ window.addEventListener("DOMContentLoaded", () => {
removeSearchModal();
});

// close the search modal if the user pressed
// Escape button
document.addEventListener("keydown", e => {
if (e.keyCode === 27) {
removeSearchModal();
}
});

// open search modal if "forward slash" button is pressed
document.addEventListener("keydown", e => {
if (e.keyCode === 191 && !isModalVisible()) {
Expand Down
Loading