Merge pull request #675 from sharetribe/smoothscroll-new-wzrd

Create listing flow: smooth scrolling polyfill to scroll to correct tab
This commit is contained in:
Vesa Luusua 2018-01-26 16:02:45 +02:00 committed by GitHub
commit ed7aac088e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -101,6 +101,11 @@ class EditListingWizard extends Component {
// Having this info in state would trigger unnecessary rerendering
this.hasScrolledToTab = false;
this.handleCreateFlowTabScrolling = this.handleCreateFlowTabScrolling.bind(this);
}
handleCreateFlowTabScrolling(shouldScroll) {
this.hasScrolledToTab = shouldScroll;
}
render() {
@ -155,6 +160,7 @@ class EditListingWizard extends Component {
params={params}
listing={listing}
marketplaceTabs={TABS}
handleCreateFlowTabScrolling={this.handleCreateFlowTabScrolling}
/>
);
})}

View file

@ -44,6 +44,7 @@ const EditListingWizardTab = props => {
history,
images,
listing,
handleCreateFlowTabScrolling,
onCreateListing,
onUpdateListing,
onCreateListingDraft,
@ -68,6 +69,9 @@ const EditListingWizardTab = props => {
if (isNew) {
const onUpsertListingDraft = currentListing.id ? onUpdateListingDraft : onCreateListingDraft;
onUpsertListingDraft(updateValues);
// Create listing flow: smooth scrolling polyfill to scroll to correct tab
handleCreateFlowTabScrolling(false);
// Redirect to next tab
const pathParams = pathParamsToNextTab(params, tab, marketplaceTabs);
history.push(
@ -225,6 +229,7 @@ EditListingWizardTab.propTypes = {
images: array,
}),
handleCreateFlowTabScrolling: func.isRequired,
onCreateListing: func.isRequired,
onUpdateListing: func.isRequired,
onCreateListingDraft: func.isRequired,