Skip to content

Commit

Permalink
Trigger search modal on "Search docs" input focus (#1610)
Browse files Browse the repository at this point in the history
This is a regression introduced in
#1601

This PR triggers the search modal when clicking on the "Search docs" input from
- inside the flyout if present
- the top left navbar
  • Loading branch information
humitos authored Oct 2, 2024
1 parent 7deb68f commit 5b181b8
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sphinx_rtd_theme/static/js/versions.js_t
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,7 @@ if (themeFlyoutDisplay === "attached") {
const event = new CustomEvent("readthedocs-search-show");
document.dispatchEvent(event);
});

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

if (themeLanguageSelector || themeVersionSelector) {
Expand Down Expand Up @@ -220,3 +212,13 @@ if (themeLanguageSelector || themeVersionSelector) {
}
});
}

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

0 comments on commit 5b181b8

Please sign in to comment.