Skip to content

Commit

Permalink
Docs retain scroll position while switching pages (#3605)
Browse files Browse the repository at this point in the history
* retain scroll location

* Added delay to scroll to top
  • Loading branch information
anishagg17 authored Jun 15, 2020
1 parent 8ff1efb commit 217bcc8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src-docs/src/components/guide_page/guide_page_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export class GuidePageChrome extends Component {
this._isMounted = true;

this.scrollNavSectionIntoViewSync();
if (document.body) document.body.scrollTop = 0;
if (document.documentElement) document.documentElement.scrollTop = 0;
};

componentWillUnmount = () => {
Expand Down Expand Up @@ -125,6 +123,12 @@ export class GuidePageChrome extends Component {
this.scrollNavSectionIntoView
);
}, 0);

// To delay scroll to top when switched to a new page
setTimeout(() => {
if (document.body) document.body.scrollTop = 0;
if (document.documentElement) document.documentElement.scrollTop = 0;
}, 1);
};

onButtonClick() {
Expand Down

0 comments on commit 217bcc8

Please sign in to comment.