A platform for community discussion. Free, open, simple.
UX: Timeline should jump to the bottom of the post in single-post topics (#10503)
Joe66aa94c5153b
diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.jsindex 6337c8d2c50..a1cdb9a8e0e 100644--- a/app/assets/javascripts/discourse/app/controllers/topic.js+++ b/app/assets/javascripts/discourse/app/controllers/topic.js@@ -721,8 +721,12 @@ export default Controller.extend(bufferedProperty("model"), {},jumpBottom() {+ // When a topic only has one lengthy post+ const jumpEnd = this.model.highest_post_number === 1 ? true : false;+DiscourseURL.routeTo(this.get("model.lastPostUrl"), {- skipIfOnScreen: false+ skipIfOnScreen: false,+ jumpEnd});},diff --git a/app/assets/javascripts/discourse/app/lib/url.js b/app/assets/javascripts/discourse/app/lib/url.jsindex aa7fbb79cb4..a7e5dccacad 100644--- a/app/assets/javascripts/discourse/app/lib/url.js+++ b/app/assets/javascripts/discourse/app/lib/url.js@@ -35,6 +35,11 @@ const SERVER_SIDE_ONLY = [/^\/invites\//];+// The amount of height (in pixles) that we factor in when jumpEnd is called so+// that we show a little bit of the post text even on mobile devices instead of+// scrolling to "suggested topics".+const JUMP_END_BUFFER = 250;+export function rewritePath(path) {const params = path.split("?");@@ -110,13 +115,9 @@ const DiscourseURL = EmberObject.extend({let holderHeight = $holder.height();let windowHeight = $(window).height() - offsetCalculator();- // 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 - holderHeight / 10)+ $holder.offset().top + (holderHeight - JUMP_END_BUFFER));_transitioning = false;return;