autodoc: Use the search input's value on load (#24467)

Co-authored-by: massi <git@massi.world>
This commit is contained in:
massi 2025-08-05 20:23:24 -07:00 committed by GitHub
parent d2149106a6
commit 9a158c1dae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -129,6 +129,11 @@
domSearch.addEventListener('input', onSearchChange, false);
window.addEventListener('keydown', onWindowKeyDown, false);
onHashChange(null);
if (domSearch.value) {
// user started typing a search query while the page was loading
curSearchIndex = -1;
startAsyncSearch();
}
});
});
@ -643,6 +648,7 @@
}
function onHashChange(state) {
// Use a non-null state value to prevent the window scrolling if the user goes back to this history entry.
history.replaceState({}, "");
navigate(location.hash);
if (state == null) window.scrollTo({top: 0});
@ -650,13 +656,11 @@
function onPopState(ev) {
onHashChange(ev.state);
syncDomSearch();
}
function navigate(location_hash) {
updateCurNav(location_hash);
if (domSearch.value !== curNavSearch) {
domSearch.value = curNavSearch;
}
render();
if (imFeelingLucky) {
imFeelingLucky = false;
@ -664,6 +668,12 @@
}
}
function syncDomSearch() {
if (domSearch.value !== curNavSearch) {
domSearch.value = curNavSearch;
}
}
function activateSelectedResult() {
if (domSectSearchResults.classList.contains("hidden")) {
return;