Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7781636

Browse files
committedJan 14, 2022
Link sidebar "location" heading to top of page
This makes it easy, when you are scrolled far down in a page, to jump back to the top.
1 parent 256721e commit 7781636

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎src/librustdoc/html/render/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer) {
17371737
{
17381738
write!(
17391739
buffer,
1740-
"<h2 class=\"location\">{}{}</h2>",
1740+
"<h2 class=\"location\"><a href=\"#\">{}{}</a></h2>",
17411741
match *it.kind {
17421742
clean::StructItem(..) => "Struct ",
17431743
clean::TraitItem(..) => "Trait ",

‎src/test/rustdoc-gui/sidebar.goml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ click: "#structs + .item-table .item-left > a"
2222
assert-count: (".sidebar .location", 2)
2323
// We check that there is no crate listed outside of the top level.
2424
assert-false: ".sidebar-elems > .crate"
25+
26+
click: ".sidebar-links a"
27+
assert-property: ("html", {"scrollTop": "389"})
28+
29+
click: ".sidebar h2.location"
30+
assert-property: ("html", {"scrollTop": "0"})
31+
2532
// We now go back to the crate page to click on the "lib2" crate link.
2633
goto: file://|DOC_PATH|/test_docs/index.html
2734
click: ".sidebar-elems .crate > ul > li:first-child > a"

0 commit comments

Comments
 (0)
Please sign in to comment.