This commit is contained in:
Tom Moor
2018-06-23 18:11:01 -07:00
parent 891c6f1c0a
commit d529c98983
3 changed files with 14 additions and 7 deletions

View File

@@ -5,9 +5,16 @@ import { withRouter } from 'react-router-dom';
class ScrollToTop extends React.Component<*> {
componentDidUpdate(prevProps) {
if (this.props.location !== prevProps.location) {
window.scrollTo(0, 0);
}
if (this.props.location.pathname === prevProps.location.pathname) return;
// exception for when entering or exiting document edit, scroll postion should not reset
if (
this.props.location.pathname.match(/\/edit\/?$/) ||
prevProps.location.pathname.match(/\/edit\/?$/)
)
return;
window.scrollTo(0, 0);
}
render() {