From 5dd68bf90046a1044f0c11520d84a68a9ff8e29a Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Wed, 2 Apr 2025 06:33:59 +0300 Subject: [PATCH] Reset sidebar scroll position on map pan in place history Otherwise the user may not notice that the list was completely reloaded. Also it makes sense to start looking at the top of the reloaded list. Without resetting the scroll position, the bottom is likely to be shown if the user went on to browse the list and pressed "Load more" a few times. --- app/assets/javascripts/index/history.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/index/history.js b/app/assets/javascripts/index/history.js index a05987214..a23a198df 100644 --- a/app/assets/javascripts/index/history.js +++ b/app/assets/javascripts/index/history.js @@ -155,10 +155,12 @@ OSM.History = function (map) { if (data.has("before")) { const [firstItem] = $("#sidebar_content .changesets ol").children().first(); firstItem?.scrollIntoView(); - } - if (data.has("after")) { + } else if (data.has("after")) { const [lastItem] = $("#sidebar_content .changesets ol").children().last(); lastItem?.scrollIntoView(false); + } else { + const [sidebar] = $("#sidebar"); + sidebar.scrollTop = 0; } updateMap(); -- 2.39.5