diff --git a/framework/core/js/src/common/components/Page.js b/framework/core/js/src/common/components/Page.js index 0d0a4afd8..4db613649 100644 --- a/framework/core/js/src/common/components/Page.js +++ b/framework/core/js/src/common/components/Page.js @@ -29,6 +29,13 @@ export default class Page extends Component { * @type {Boolean} */ this.scrollTopOnCreate = true; + + /** + * Whether the browser should restore scroll state on refreshes. + * + * @type {Boolean} + */ + this.useBrowserScrollRestoration = true; } oncreate(vnode) { @@ -41,6 +48,10 @@ export default class Page extends Component { if (this.scrollTopOnCreate) { $(window).scrollTop(0); } + + if ('scrollRestoration' in history) { + history.scrollRestoration = this.useBrowserScrollRestoration ? 'auto' : 'manual'; + } } onremove() { diff --git a/framework/core/js/src/forum/components/DiscussionPage.js b/framework/core/js/src/forum/components/DiscussionPage.js index c5812bf39..beb0b2a5d 100644 --- a/framework/core/js/src/forum/components/DiscussionPage.js +++ b/framework/core/js/src/forum/components/DiscussionPage.js @@ -18,6 +18,8 @@ export default class DiscussionPage extends Page { oninit(vnode) { super.oninit(vnode); + this.useBrowserScrollRestoration = false; + /** * The discussion that is being viewed. *