Skip to content

Commit 7b00534

Browse files
committed
rustdoc: fix corner case in search keyboard commands
1 parent 96ddd32 commit 7b00534

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,7 @@ function initSearch(rawSearchIndex) {
14911491
const target = searchState.focusedByTab[searchState.currentTab] ||
14921492
document.querySelectorAll(".search-results.active a").item(0) ||
14931493
document.querySelectorAll("#titles > button").item(searchState.currentTab);
1494+
searchState.focusedByTab[searchState.currentTab] = null;
14941495
if (target) {
14951496
target.focus();
14961497
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Checks that the search tab results work correctly with function signature syntax
2+
// First, try a search-by-name
3+
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
4+
write: (".search-input", "Foo")
5+
// To be SURE that the search will be run.
6+
press-key: 'Enter'
7+
// Waiting for the search results to appear...
8+
wait-for: "#titles"
9+
10+
// Now use the keyboard commands to switch to the third result.
11+
press-key: "ArrowDown"
12+
press-key: "ArrowDown"
13+
press-key: "ArrowDown"
14+
assert: ".search-results.active > a:focus:nth-of-type(3)"
15+
16+
// Now switch to the second tab, then back to the first one, then arrow back up.
17+
press-key: "ArrowRight"
18+
assert: ".search-results.active:nth-of-type(2) > a:focus:nth-of-type(1)"
19+
press-key: "ArrowLeft"
20+
assert: ".search-results.active:nth-of-type(1) > a:focus:nth-of-type(3)"
21+
press-key: "ArrowUp"
22+
assert: ".search-results.active > a:focus:nth-of-type(2)"
23+
press-key: "ArrowUp"
24+
assert: ".search-results.active > a:focus:nth-of-type(1)"
25+
press-key: "ArrowUp"
26+
assert: ".search-input:focus"
27+
press-key: "ArrowDown"
28+
assert: ".search-results.active > a:focus:nth-of-type(1)"

0 commit comments

Comments
 (0)