From 136174e0eec7d5cfaefac657a919c19e587fa7c9 Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Fri, 30 Sep 2022 21:27:41 +0530 Subject: [PATCH] FEATURE: when entering a topic scroll to last visited line marker (#18440) When a user enters a topic they have already visited they are navigated to that post that is newest for them (post_number_last_read + 1). Above that post there is a "last visited" line marker which is visible when the user scrolls a bit above the post they landed on. This commit makes sure that the "last visited" line marker is visible as soon as user is landed in the topic. --- app/assets/javascripts/discourse/app/lib/url.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/assets/javascripts/discourse/app/lib/url.js b/app/assets/javascripts/discourse/app/lib/url.js index 622911c4173..1d979f4c568 100644 --- a/app/assets/javascripts/discourse/app/lib/url.js +++ b/app/assets/javascripts/discourse/app/lib/url.js @@ -117,6 +117,15 @@ const DiscourseURL = EmberObject.extend({ if (!holder) { selector = holderId; + + if ( + document.getElementsByClassName( + `topic-post-visited-line post-${postNumber - 1}` + )?.length === 1 + ) { + selector = ".small-action.topic-post-visited"; + } + holder = document.querySelector(selector); }