Skip to content

Commit

Permalink
Integrate with Read the Docs Addons search modal
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed Oct 31, 2024
1 parent 9a7d2c3 commit 9dae618
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ document.addEventListener('DOMContentLoaded', () => {

// Sphinx compatibility.
// Prior to Sphinx 7.2, URL_ROOT was part of DOCUMENTATION_OPTIONS.
let URL_ROOT = "";
let URL_ROOT = '';
// Sphinx >= 7.2
if (document.documentElement.dataset.content_root) {
URL_ROOT = document.documentElement.dataset.content_root;
Expand Down Expand Up @@ -156,3 +156,12 @@ document.addEventListener('DOMContentLoaded', () => {
});
}
});

document.addEventListener('readthedocs-addons-data-ready', () => {
// Trigger the Read the Docs Addons Search modal when clicking on "Search docs" input from the topnav.
document
.querySelector("[role='search'] input")
?.addEventListener('focusin', () => {
document.dispatchEvent(new CustomEvent('readthedocs-search-show'));
});
});

0 comments on commit 9dae618

Please sign in to comment.