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 @@...@@ -129,6 +129,11 @@
129 domSearch.addEventListener('input', onSearchChange, false);129 domSearch.addEventListener('input', onSearchChange, false);
130 window.addEventListener('keydown', onWindowKeyDown, false);130 window.addEventListener('keydown', onWindowKeyDown, false);
131 onHashChange(null);131 onHashChange(null);
132 if (domSearch.value) {
133 // user started typing a search query while the page was loading
134 curSearchIndex = -1;
135 startAsyncSearch();
136 }
132 });137 });
133 });138 });
134139
...@@ -643,6 +648,7 @@...@@ -643,6 +648,7 @@
643 }648 }
644649
645 function onHashChange(state) {650 function onHashChange(state) {
651 // Use a non-null state value to prevent the window scrolling if the user goes back to this history entry.
646 history.replaceState({}, "");652 history.replaceState({}, "");
647 navigate(location.hash);653 navigate(location.hash);
648 if (state == null) window.scrollTo({top: 0});654 if (state == null) window.scrollTo({top: 0});
...@@ -650,13 +656,11 @@...@@ -650,13 +656,11 @@
650656
651 function onPopState(ev) {657 function onPopState(ev) {
652 onHashChange(ev.state);658 onHashChange(ev.state);
659 syncDomSearch();
653 }660 }
654661
655 function navigate(location_hash) {662 function navigate(location_hash) {
656 updateCurNav(location_hash);663 updateCurNav(location_hash);
657 if (domSearch.value !== curNavSearch) {
658 domSearch.value = curNavSearch;
659 }
660 render();664 render();
661 if (imFeelingLucky) {665 if (imFeelingLucky) {
662 imFeelingLucky = false;666 imFeelingLucky = false;
...@@ -664,6 +668,12 @@...@@ -664,6 +668,12 @@
664 }668 }
665 }669 }
666670
671 function syncDomSearch() {
672 if (domSearch.value !== curNavSearch) {
673 domSearch.value = curNavSearch;
674 }
675 }
676
667 function activateSelectedResult() {677 function activateSelectedResult() {
668 if (domSectSearchResults.classList.contains("hidden")) {678 if (domSectSearchResults.classList.contains("hidden")) {
669 return;679 return;