Skip to content

Commit 51a99eb

Browse files
Rollup merge of #85506 - GuillaumeGomez:reset-focusedByTab, r=jsha
Reset "focusedByTab" field when doing another search Fixes #85467. The problem was simply that we forget to reset the `focusedByTab` field, which was still referring to removed DOM elements. r? ``@jsha``
2 parents af2ed1b + b8909fc commit 51a99eb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/librustdoc/html/static/search.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -885,12 +885,12 @@ window.initSearch = function(rawSearchIndex) {
885885
focusSearchResult();
886886
}
887887

888-
// focus the first search result on the active tab, or the result that
888+
// Focus the first search result on the active tab, or the result that
889889
// was focused last time this tab was active.
890890
function focusSearchResult() {
891891
var target = searchState.focusedByTab[searchState.currentTab] ||
892-
document.querySelectorAll(".search-results.active a").item(0) ||
893-
document.querySelectorAll("#titles > button").item(searchState.currentTab);
892+
document.querySelectorAll(".search-results.active a").item(0) ||
893+
document.querySelectorAll("#titles > button").item(searchState.currentTab);
894894
if (target) {
895895
target.focus();
896896
}
@@ -1076,6 +1076,8 @@ window.initSearch = function(rawSearchIndex) {
10761076
ret_others[0] + ret_in_args[0] + ret_returned[0] + "</div>";
10771077

10781078
search.innerHTML = output;
1079+
// Reset focused elements.
1080+
searchState.focusedByTab = [null, null, null];
10791081
searchState.showResults(search);
10801082
var elems = document.getElementById("titles").childNodes;
10811083
elems[0].onclick = function() { printTab(0); };
@@ -1365,7 +1367,6 @@ window.initSearch = function(rawSearchIndex) {
13651367
if (e.which === 38) { // up
13661368
var previous = document.activeElement.previousElementSibling;
13671369
if (previous) {
1368-
console.log("previousElementSibling", previous);
13691370
previous.focus();
13701371
} else {
13711372
searchState.focus();

0 commit comments

Comments
 (0)