mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
autodoc: Use the search input's value on load (#24467)
Co-authored-by: massi <git@massi.world>
This commit is contained in:
parent
d2149106a6
commit
9a158c1dae
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user