Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboarding: Fix going back from Checkout to Stepper #97074

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import { useStepPersistedState } from '@automattic/onboarding';
import { withShoppingCart } from '@automattic/shopping-cart';
import { localize } from 'i18n-calypso';
import { isEmpty } from 'lodash';
import { useRef, useCallback, useEffect } from 'react';
import { useRef, useCallback } from 'react';
import { connect } from 'react-redux';
import { recordUseYourDomainButtonClick } from 'calypso/components/domains/register-domain-step/analytics';
import { planItem } from 'calypso/lib/cart-values/cart-items';
import CalypsoShoppingCartProvider from 'calypso/my-sites/checkout/calypso-shopping-cart-provider';
import withCartKey from 'calypso/my-sites/checkout/with-cart-key';
import { RenderDomainsStep, submitDomainStepSelection } from 'calypso/signup/steps/domains';
import {
wasSignupCheckoutPageUnloaded,
retrieveSignupDestination,
getSignupCompleteFlowName,
} from 'calypso/signup/storageUtils';
import { recordTracksEvent } from 'calypso/state/analytics/actions';
import { NON_PRIMARY_DOMAINS_TO_FREE_USERS } from 'calypso/state/current-user/constants';
import {
Expand Down Expand Up @@ -100,18 +95,6 @@ export default function DomainsStep( props: StepProps ) {
},
[ stepState, setStepState ]
);
useEffect( () => {
// This will automatically submit the domains step when navigating back from checkout
// It will redirect the user to plans step. The idea is to achieve the same behavior as /start.
const signupDestinationCookieExists = retrieveSignupDestination();
const isReEnteringFlow = getSignupCompleteFlowName() === props.flow;
const isManageSiteFlow = Boolean(
wasSignupCheckoutPageUnloaded() && signupDestinationCookieExists && isReEnteringFlow
);
if ( isManageSiteFlow ) {
props.navigation.submit?.( stepState );
}
}, [ stepState, props.navigation, props.flow ] );

return (
<CalypsoShoppingCartProvider>
Expand Down
2 changes: 1 addition & 1 deletion client/landing/stepper/declarative-flow/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const onboarding: Flow = {
}
}
setSignupCompleteFlowName( flowName );
return navigate( 'create-site', undefined, true );
return navigate( 'create-site', undefined, false );
}
case 'create-site':
return navigate( 'processing', undefined, true );
Expand Down
Loading