From eed59b713a1859198a802419328e55799e562193 Mon Sep 17 00:00:00 2001 From: WilliamKoza Date: Sat, 26 Jan 2019 10:14:18 +0100 Subject: [PATCH] fix(docs-infra): avoid a race-condition with navigating forward/back and immediately reloading (#28368) This can result in an inconsistent state PR Close #28368 --- aio/src/app/shared/scroll.service.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aio/src/app/shared/scroll.service.ts b/aio/src/app/shared/scroll.service.ts index de48dcec68..222c916f7c 100644 --- a/aio/src/app/shared/scroll.service.ts +++ b/aio/src/app/shared/scroll.service.ts @@ -62,6 +62,9 @@ export class ScrollService { if (event.type === 'hashchange') { this.scrollToPosition(); } else { + // Navigating with forward/back, we have to remove the position from the session storage in order to avoid a + // race-condition + this.removeStoredScrollPosition(); // The popstate event is always triggered by doing a browser action such as a click on the back or forward button. // It can be follow by a event of type `hashchange`. this.popStateFired = true;