Skip to content

Commit b51be1f

Browse files
committed
#2671: Do not scroll to top for anchored entries, because they are never cached.
1 parent e894da2 commit b51be1f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

assets/javascripts/views/content/content.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,12 @@ app.views.Content = class Content extends app.View {
150150
beforeRoute(context) {
151151
this.cacheScrollPosition();
152152

153-
// If scroll position wasn't cached from an earlier visit, scroll to top.
154-
if (!this.scrollMap[context.state.id]) {
153+
/*
154+
* If scroll position wasn't cached from an earlier visit:
155+
* - let the anchor (if there is one) set position, or
156+
* - scroll to top.
157+
*/
158+
if (!this.scrollMap[context.state.id] && !context.hash) {
155159
this.scrollToTop();
156160
}
157161

lib/docs/filters/nim/clean_html.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def call
5858
css('a', 'dl', 'table', 'code').remove_attr('class')
5959
css('table').remove_attr('border')
6060

61+
# Remove Source/Edit links.
62+
css('dd > a').each do |node|
63+
node.remove if node.inner_html == 'Source' || node.inner_html == 'Edit'
64+
end
65+
6166
doc
6267
end
6368
end

0 commit comments

Comments
 (0)