Skip to content

Commit d8b60ba

Browse files
authored
Fix flickering back button between signup and domains step (#102022)
* Fix flickering back button between signup and domains step * Add comment
1 parent 6193da1 commit d8b60ba

File tree

1 file changed

+7
-1
lines changed
  • client/landing/stepper/declarative-flow/internals/hooks/use-step-navigation-with-tracking

1 file changed

+7
-1
lines changed

client/landing/stepper/declarative-flow/internals/hooks/use-step-navigation-with-tracking/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,15 @@ export const useStepNavigationWithTracking = ( {
4747
/**
4848
* If the previous step is defined in the store, and the current step is not the first step, we can go back.
4949
* We need to make sure we're not at the first step because `previousStep` is persisted and can be a step from another flow or another run of the current flow.
50+
* We include a check for whether the previous step is the same sort of step as the current step. This can happen briefly while transitioning from one step to
51+
* the next where the onboard store data has updated, but `currentStepRoute` hasn't yet because the step hasn't been rendered yet. This would cause the back button
52+
* to flash briefly while navigating.
5053
*/
5154
const canUserGoBack =
52-
stepData?.previousStep && currentStepRoute !== stepSlugs[ 0 ] && history.length > 1;
55+
stepData?.previousStep &&
56+
currentStepRoute !== stepSlugs[ 0 ] &&
57+
history.length > 1 &&
58+
stepData.previousStep !== currentStepRoute;
5359

5460
const tracksEventPropsFromFlow = flow.useTracksEventProps?.();
5561

0 commit comments

Comments
 (0)