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
This commit is contained in:
WilliamKoza 2019-01-26 10:14:18 +01:00 committed by Matias Niemelä
parent b2a6bf2a80
commit eed59b713a
1 changed files with 3 additions and 0 deletions

View File

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