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
This commit is contained in:
David Taylor 2023-08-28 12:23:02 +01:00 committed by GitHub
parent 997c839626
commit 33d5845991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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