Skip to content

Node.js based forum software built for the modern web

fix: race condition where `navigator.update` was called when it should not be

Julian Lamfa643eb80893
diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js
index 2dcbdb6aec..e6933999c7 100644
--- a/public/src/modules/navigator.js
+++ b/public/src/modules/navigator.js
@@ -581,9 +581,9 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct
function animateScroll() {
function reenableScroll() {
// Re-enable onScroll behaviour
- $(window).on('scroll', navigator.delayedUpdate);
- const scrollToRect = scrollTo.get(0).getBoundingClientRect();
- navigator.update(scrollToRect.top);
+ setTimeout(() => { // fixes race condition from jQuery — onAnimateComplete called too quickly
+ $(window).on('scroll', navigator.delayedUpdate);
+ }, 50);
}
function onAnimateComplete() {
if (done) {