Skip to content

Commit 9164b48

Browse files
ZexbeJoshua Nelson
authored and
Joshua Nelson
committed
Fix Chrome, and Safari scrolling + anchor in docs
1 parent 93a59ab commit 9164b48

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

templates/rustdoc.hbs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,25 @@
1010
</head>
1111
<body>
1212
{{> navigation_rustdoc}}
13-
<div class="{{content.rustdoc_body_class}}" tabindex="1">
13+
<div id="rustdoc_body_wrapper" class="{{content.rustdoc_body_class}}" tabindex="-1">
1414
{{{content.rustdoc_body}}}
1515
</div>
1616
<script type="text/javascript" src="/menu.js?{{cratesfyi_version_safe}}"></script>
1717
</body>
18+
<script>
19+
var doc_body = document.getElementById("rustdoc_body_wrapper");
20+
if(window.location.hash) {
21+
var notFirefox = typeof InstallTrigger === 'undefined';
22+
if(notFirefox) {
23+
var hash = window.location.hash;
24+
window.location.hash = "";
25+
setTimeout(function () {
26+
window.location.hash = hash;
27+
doc_body.focus();
28+
}, 1);
29+
}
30+
} else {
31+
doc_body.focus();
32+
}
33+
</script>
1834
</html>

0 commit comments

Comments
 (0)