diff --git a/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js b/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js index b56a3124677..ad8f629179f 100644 --- a/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js +++ b/app/assets/javascripts/discourse/app/components/scrolling-post-stream.js @@ -206,15 +206,18 @@ export default MountWidget.extend({ return element.offsetTop + getOffsetTop(element.offsetParent); }; - const top = getOffsetTop(refreshedElem) - offsetCalculator(); - window.scrollTo({ top }); + window.scrollTo({ + top: getOffsetTop(refreshedElem) - offsetCalculator(), + }); // This seems weird, but somewhat infrequently a rerender // will cause the browser to scroll to the top of the document // in Chrome. This makes sure the scroll works correctly if that // happens. schedule("afterRender", () => { - window.scrollTo({ top }); + window.scrollTo({ + top: getOffsetTop(refreshedElem) - offsetCalculator(), + }); }); }); };