FIX: disable browser `history.scrollRestoration` feature (#24550)

When going 'back', default browser behavior is to restore the scroll position. Unfortunately sites are given no control over the timing of this restoration, which means it can happen halfway through an Ember transition. Therefore we disable it, and re-implement the functionality in our scroll-manager service.

We inadvertently dropped this configuration in 7c9cf666da, which led to issues like https://meta.discourse.org/t/286463
This commit is contained in:
David Taylor 2023-11-25 00:56:19 +00:00 committed by GitHub
parent bf9c0c4889
commit 34a859d628
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -44,6 +44,10 @@ const Discourse = Application.extend({
Error.stackTraceLimit = Infinity;
}
// Our scroll-manager service takes care of storing and restoring scroll position.
// Disable browser handling:
window.history.scrollRestoration = "manual";
loadInitializers(this);
},