Skip to content

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

Fix mobile topic-timeline not closing on scrolling past last post (#8730)

Martin Brennan18bba860b559
diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6
index 7b523ee7680..8e2e17b2819 100644
--- a/app/assets/javascripts/discourse/controllers/topic.js.es6
+++ b/app/assets/javascripts/discourse/controllers/topic.js.es6
@@ -727,6 +727,10 @@ export default Controller.extend(bufferedProperty("model"), {
},
jumpEnd() {
+ this.appEvents.trigger(
+ "topic:jump-to-post",
+ this.get("model.highest_post_number")
+ );
DiscourseURL.routeTo(this.get("model.lastPostUrl"), {
jumpEnd: true
});
diff --git a/app/assets/javascripts/discourse/lib/url.js.es6 b/app/assets/javascripts/discourse/lib/url.js.es6
index bb5d8d31a04..6d7fa31966e 100644
--- a/app/assets/javascripts/discourse/lib/url.js.es6
+++ b/app/assets/javascripts/discourse/lib/url.js.es6
@@ -103,11 +103,14 @@ const DiscourseURL = EmberObject.extend({
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
+ // scroll to the bottom of the post and if the post is yuge we go back up the
+ // timeline by a small % of the post height so we can see the bottom of the text.
+ //
+ // otherwise just jump to the top of the post using the lock & holder method.
if (holderHeight > windowHeight) {
- $(window).scrollTop($holder.offset().top + holderHeight);
+ $(window).scrollTop(
+ $holder.offset().top + (holderHeight - holderHeight / 10)
+ );
_transitioning = false;
return;
}