authorgravatar for mdsiboldi@gmail.commassi <mdsiboldi@gmail.com> 2025-08-05 20:23:24-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-08-06 03:23:24+00:00
log9a158c1dae531f2a4e5667569bed38c27cbd4d57
tree6e83d80b4c9b9dd59d84598d684e1312082ad4f3
parentd2149106a6c03301d0467283814db86be030b335
signaturebadge-check Signed by PGP key B5690EEEBB952194

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

Co-authored-by: massi <git@massi.world>

1 files changed, 13 insertions(+), 3 deletions(-)

lib/docs/main.js+13-3
......@@ -129,6 +129,11 @@
129129 domSearch.addEventListener('input', onSearchChange, false);
130130 window.addEventListener('keydown', onWindowKeyDown, false);
131131 onHashChange(null);
132 if (domSearch.value) {
133 // user started typing a search query while the page was loading
134 curSearchIndex = -1;
135 startAsyncSearch();
136 }
132137 });
133138 });
134139
......@@ -643,6 +648,7 @@
643648 }
644649
645650 function onHashChange(state) {
651 // Use a non-null state value to prevent the window scrolling if the user goes back to this history entry.
646652 history.replaceState({}, "");
647653 navigate(location.hash);
648654 if (state == null) window.scrollTo({top: 0});
......@@ -650,13 +656,11 @@
650656
651657 function onPopState(ev) {
652658 onHashChange(ev.state);
659 syncDomSearch();
653660 }
654661
655662 function navigate(location_hash) {
656663 updateCurNav(location_hash);
657 if (domSearch.value !== curNavSearch) {
658 domSearch.value = curNavSearch;
659 }
660664 render();
661665 if (imFeelingLucky) {
662666 imFeelingLucky = false;
......@@ -664,6 +668,12 @@
664668 }
665669 }
666670
671 function syncDomSearch() {
672 if (domSearch.value !== curNavSearch) {
673 domSearch.value = curNavSearch;
674 }
675 }
676
667677 function activateSelectedResult() {
668678 if (domSectSearchResults.classList.contains("hidden")) {
669679 return;