mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +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
1 changed files with 13 additions and 3 deletions
|
|
@ -129,6 +129,11 @@
|
||||||
domSearch.addEventListener('input', onSearchChange, false);
|
domSearch.addEventListener('input', onSearchChange, false);
|
||||||
window.addEventListener('keydown', onWindowKeyDown, false);
|
window.addEventListener('keydown', onWindowKeyDown, false);
|
||||||
onHashChange(null);
|
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) {
|
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({}, "");
|
history.replaceState({}, "");
|
||||||
navigate(location.hash);
|
navigate(location.hash);
|
||||||
if (state == null) window.scrollTo({top: 0});
|
if (state == null) window.scrollTo({top: 0});
|
||||||
|
|
@ -650,13 +656,11 @@
|
||||||
|
|
||||||
function onPopState(ev) {
|
function onPopState(ev) {
|
||||||
onHashChange(ev.state);
|
onHashChange(ev.state);
|
||||||
|
syncDomSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigate(location_hash) {
|
function navigate(location_hash) {
|
||||||
updateCurNav(location_hash);
|
updateCurNav(location_hash);
|
||||||
if (domSearch.value !== curNavSearch) {
|
|
||||||
domSearch.value = curNavSearch;
|
|
||||||
}
|
|
||||||
render();
|
render();
|
||||||
if (imFeelingLucky) {
|
if (imFeelingLucky) {
|
||||||
imFeelingLucky = false;
|
imFeelingLucky = false;
|
||||||
|
|
@ -664,6 +668,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function syncDomSearch() {
|
||||||
|
if (domSearch.value !== curNavSearch) {
|
||||||
|
domSearch.value = curNavSearch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function activateSelectedResult() {
|
function activateSelectedResult() {
|
||||||
if (domSectSearchResults.classList.contains("hidden")) {
|
if (domSectSearchResults.classList.contains("hidden")) {
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue