This commit is contained in:
Albert Juhé Lluveras 2019-04-08 19:53:28 +02:00 committed by GitHub
parent f47f1097bb
commit baf3bc3e28
1 changed files with 8 additions and 1 deletions

View File

@ -72,6 +72,10 @@ const getPages = () => {
};
class Controller extends Component {
componentDidMount() {
window.document.documentElement.scrollTop = 0;
}
componentDidUpdate( prevProps ) {
const prevQuery = this.getQuery( prevProps.location.search );
const prevBaseQuery = this.getBaseQuery( prevProps.location.search );
@ -80,6 +84,10 @@ class Controller extends Component {
if ( prevQuery.page > 1 && ! isEqual( prevBaseQuery, baseQuery ) ) {
getHistory().replace( getNewPath( { page: 1 } ) );
}
if ( prevProps.match.url !== this.props.match.url ) {
window.document.documentElement.scrollTop = 0;
}
}
getQuery( searchString ) {
@ -104,7 +112,6 @@ class Controller extends Component {
const page = find( getPages(), { path } );
window.wpNavMenuUrlUpdate( page, query );
window.wpNavMenuClassChange( page );
window.document.documentElement.scrollTop = 0;
return createElement( page.container, { params, path: url, pathMatch: path, query } );
}
}