Skip to content

A platform for community discussion. Free, open, simple.

FIX: Make scrolling to bottom post in topic more consistent (#8671)

Martin Brennanbdff4561d4e2
diff --git a/app/assets/javascripts/discourse/lib/url.js.es6 b/app/assets/javascripts/discourse/lib/url.js.es6
index ae252facf8e..bb5d8d31a04 100644
--- a/app/assets/javascripts/discourse/lib/url.js.es6
+++ b/app/assets/javascripts/discourse/lib/url.js.es6
@@ -99,9 +99,18 @@ const DiscourseURL = EmberObject.extend({
let holder;
if (opts.jumpEnd) {
- $(window).scrollTop($(document).height() - $(window).height());
- _transitioning = false;
- return;
+ let $holder = $(holderId);
+ let holderHeight = $holder.height();
+ let windowHeight = $(window).height() - offsetCalculator();
+
+ // scroll to the bottom of the post and stop any further action if the
+ // post is yuge, otherwise just jump to the top of the post
+ // using the lock & holder method
+ if (holderHeight > windowHeight) {
+ $(window).scrollTop($holder.offset().top + holderHeight);
+ _transitioning = false;
+ return;
+ }
}
if (postNumber === 1 && !opts.anchor) {
diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6
index dbfeb2a389c..72157d7910c 100644
--- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6
+++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6
@@ -263,7 +263,7 @@ createWidget("timeline-scrollarea", {
const position = this.position();
this.state.scrolledPost = position.current;
- if (position.current === position.scrollPosition || this.site.mobileView) {
+ if (position.current === position.scrollPosition) {
this.sendWidgetAction("jumpToIndex", position.current);
} else {
this.sendWidgetAction("jumpEnd");