Skip to content

Commit 2caeeb0

Browse files
committed
Auto merge of #83028 - GuillaumeGomez:prevent-js-error-if-no-filter, r=Nemo157
Prevent JS error when there is no dependency or other crate documented (or --disable-per-crate-search has been used) When there is only one crate, the dropdown is removed, creating an error (that you can see pretty easily on docs.rs for example). r? `@jyn514`
2 parents 1381dcf + 56898ec commit 2caeeb0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustdoc/html/static/main.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2948,7 +2948,11 @@ function defocusSearchBar() {
29482948
search_input.removeAttribute('disabled');
29492949

29502950
var crateSearchDropDown = document.getElementById("crate-search");
2951-
crateSearchDropDown.addEventListener("focus", loadSearch);
2951+
// `crateSearchDropDown` can be null in case there is only crate because in that case, the
2952+
// crate filter dropdown is removed.
2953+
if (crateSearchDropDown) {
2954+
crateSearchDropDown.addEventListener("focus", loadSearch);
2955+
}
29522956
var params = getQueryStringParams();
29532957
if (params.search !== undefined) {
29542958
loadSearch();

0 commit comments

Comments
 (0)