From 33d584599176b09b729d0a0e14e82ff6faf9252b Mon Sep 17 00:00:00 2001 From: David Taylor Date: Mon, 28 Aug 2023 12:23:02 +0100 Subject: [PATCH] FIX: Avoid scroll jumping for topics on slow connections (#23290) When the 'loading slider' navigation indicator is enabled, and a connection is very slow, we `display: none` most of the page and display a spinner. The `still-loading` body class for this was being added in the `afterRender` step in the Ember runloop. This meant that, depending on the order they were scheduled, other `afterRender` jobs may run before it. This caused an issue with topic scroll locations because we would attempt to scroll to an element which was `display: none` at the point its position was calculated. This commit moves the `still-loading` class manipulations to the `render` step of the runloop, which is technically more correct, and means that anything scheduled in the `afterRender` step is guaranteed to run without the `display: none` CSS. https://meta.discourse.org/t/276305/29 --- .../javascripts/discourse/app/services/loading-slider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/services/loading-slider.js b/app/assets/javascripts/discourse/app/services/loading-slider.js index 08f1bb04e14..a73097a729b 100644 --- a/app/assets/javascripts/discourse/app/services/loading-slider.js +++ b/app/assets/javascripts/discourse/app/services/loading-slider.js @@ -108,13 +108,13 @@ export default class LoadingSlider extends Service.extend(Evented) { this.trigger("stateChanged", false); this.scheduleManager.cancelAll(); - this.scheduleManager.schedule("afterRender", this.removeClasses); + this.scheduleManager.schedule("render", this.removeClasses); } @bind setStillLoading() { this.stillLoading = true; - this.scheduleManager.schedule("afterRender", this.addStillLoadingClass); + this.scheduleManager.schedule("render", this.addStillLoadingClass); } @bind