Prevent JS error when there is no dependency or other crate documented

This commit is contained in:
Guillaume Gomez 2021-03-11 21:13:42 +01:00
parent 4b9f5cc4c1
commit 56898ec6a7

View File

@ -2955,7 +2955,11 @@ function defocusSearchBar() {
enableSearchInput();
var crateSearchDropDown = document.getElementById("crate-search");
crateSearchDropDown.addEventListener("focus", loadSearch);
// `crateSearchDropDown` can be null in case there is only crate because in that case, the
// crate filter dropdown is removed.
if (crateSearchDropDown) {
crateSearchDropDown.addEventListener("focus", loadSearch);
}
var params = getQueryStringParams();
if (params.search !== undefined) {
loadSearch();