Onboarding: Scroll to top when navigating between pages (https://github.com/woocommerce/woocommerce-admin/pull/3122)

* Scroll to top when navigating between tasks

* Scroll to top when navigating between steps
This commit is contained in:
Joshua T Flowers 2019-10-30 02:24:24 +08:00 committed by Justin Shreve
parent af10516b8f
commit 9d04b15c7a
2 changed files with 11 additions and 1 deletions

View File

@ -71,6 +71,15 @@ class ProfileWizard extends Component {
this.goToNextStep = this.goToNextStep.bind( this );
}
componentDidUpdate( prevProps ) {
const { step: prevStep } = prevProps.query;
const { step } = this.props.query;
if ( prevStep !== step ) {
window.document.documentElement.scrollTop = 0;
}
}
componentDidMount() {
document.documentElement.classList.remove( 'wp-toolbar' );
document.body.classList.add( 'woocommerce-onboarding' );

View File

@ -40,10 +40,11 @@ class TaskDashboard extends Component {
}
componentDidUpdate( prevProps ) {
const { task } = this.props.query;
const { task: prevTask } = prevProps.query;
const { task } = this.props.query;
if ( prevTask !== task ) {
window.document.documentElement.scrollTop = 0;
this.recordTaskView();
}
}