Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
4934c26
fix: clicking on previous step navigates to correct step instead of next
subediDarshan Jun 30, 2025
62265a3
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jun 30, 2025
30a1ef8
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jun 30, 2025
974041f
fix: implement step navigation in WizardForm and disable navigation i…
subediDarshan Jul 1, 2025
6c51556
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jul 1, 2025
18bfdcc
Merge branch 'main' into fix/step-indicator-navigation
kart1ka Jul 1, 2025
1eb249f
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jul 10, 2025
8af6f95
fix: adjust step navigation logic in WizardForm and useWizardState
subediDarshan Jul 10, 2025
66a2d4e
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jul 10, 2025
f61e200
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jul 10, 2025
b3c3878
Merge branch 'fix/step-indicator-navigation' of https://github.com/su…
subediDarshan Jul 10, 2025
c999b7e
fix: add clarification comment in goToStep function
subediDarshan Jul 10, 2025
f8203f7
Merge remote-tracking branch 'origin' into fix/step-indicator-navigation
subediDarshan Jul 10, 2025
197db24
Merge branch 'main' into fix/step-indicator-navigation
anikdhabal Aug 13, 2025
b1ade67
Merge branch 'main' into fix/step-indicator-navigation
anikdhabal Sep 2, 2025
a081113
Merge branch 'main' into fix/step-indicator-navigation
anikdhabal Sep 3, 2025
041ae7a
Merge branch 'main' into fix/step-indicator-navigation
anikdhabal Sep 4, 2025
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 @@ -125,6 +125,13 @@ const OnboardingPage = (props: PageProps) => {
};
const currentStepIndex = steps.indexOf(currentStep);

const goToStep = (step: number) => {
const newStep = steps[step];
startTransition(() => {
router.push(`/getting-started/${stepTransform(newStep)}`);
});
};

const goToNextStep = () => {
const nextIndex = currentStepIndex + 1;
const newStep = steps[nextIndex];
Expand Down Expand Up @@ -159,7 +166,7 @@ const OnboardingPage = (props: PageProps) => {
</p>
))}
</header>
<Steps maxSteps={steps.length} currentStep={currentStepIndex + 1} nextStep={goToNextStep} />
<Steps maxSteps={steps.length} currentStep={currentStepIndex + 1} navigateToStep={goToStep} />
</div>
<StepCard>
<Suspense fallback={<Icon name="loader" />}>
Expand Down
8 changes: 4 additions & 4 deletions packages/ui/components/form/step/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import classNames from "@calcom/ui/classNames";
type StepWithNav = {
maxSteps: number;
currentStep: number;
nextStep: () => void;
navigateToStep: (step: number) => void;
disableNavigation?: false;
stepLabel?: (currentStep: number, maxSteps: number) => string;
};

type StepWithoutNav = {
maxSteps: number;
currentStep: number;
nextStep?: undefined;
navigateToStep?: undefined;
disableNavigation: true;
stepLabel?: (currentStep: number, maxSteps: number) => string;
};
Expand All @@ -23,7 +23,7 @@ const Steps = (props: StepsProps) => {
const {
maxSteps,
currentStep,
nextStep,
navigateToStep,
disableNavigation = false,
stepLabel = (currentStep, totalSteps) => `Step ${currentStep} of ${totalSteps}`,
} = props;
Expand All @@ -35,7 +35,7 @@ const Steps = (props: StepsProps) => {
return index <= currentStep - 1 ? (
<div
key={`step-${index}`}
onClick={() => nextStep?.()}
onClick={() => navigateToStep?.(index)}
className={classNames(
"bg-inverted h-1 w-full rounded-[1px]",
index < currentStep - 1 && !disableNavigation ? "cursor-pointer" : ""
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/components/form/step/steps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const mockNavigateToStep = vi.fn();
const Props = {
maxSteps: MAX_STEPS,
currentStep: CURRENT_STEP,
nextStep: mockNavigateToStep,
navigateToStep: mockNavigateToStep,
stepLabel: (currentStep: number, totalSteps: number) => `Test Step ${currentStep} of ${totalSteps}`,
disableNavigation: undefined,
};
Expand Down
5 changes: 2 additions & 3 deletions packages/ui/components/form/wizard/WizardForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function WizardForm({
defaultStep = 1,
disableNavigation = false,
}: WizardFormProps) {
const { currentStep, maxSteps, nextStep, prevStep, isFirstStep, isLastStep } = useWizardState(
const { currentStep, maxSteps, nextStep, goToStep, prevStep, isFirstStep, isLastStep } = useWizardState(
defaultStep,
steps.length
);
Expand All @@ -71,10 +71,9 @@ export function WizardForm({
<Steps
maxSteps={maxSteps}
currentStep={currentStep}
nextStep={nextStep}
navigateToStep={goToStep}
stepLabel={stepLabel}
data-testid="wizard-step-component"
disableNavigation={disableNavigation}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for removal of this props?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By not passing this prop, disableNavigation=false is set by default (default parameter set in Steps component), which is what we need since we are navigating between previous steps here through 'navigateToStep' function.

/>
)}
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/components/form/wizard/useWizardState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export function useWizardState(defaultStep = 1, maxSteps: number) {

const goToStep = useCallback(
(newStep: number) => {
setStep(Math.min(Math.max(newStep, 1), maxSteps));
// Convert 0-based newStep to 1-based for URL (?step=1), So actual step = newStep+1
setStep(Math.min(Math.max(newStep + 1, 1), maxSteps));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 'Steps' component (where this 'goToStep' function is passed as prop),
0-based indexes are passed in goToFunction as newStep,
but 1-based indexes is being used in URL query param (?step=1),
So, +1 conversion is needed here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add a comment in the code mentioning the same

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added c999b7e

},
[setStep, maxSteps]
);
Expand Down
3 changes: 1 addition & 2 deletions packages/ui/components/layout/WizardLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";

// eslint-disable-next-line no-restricted-imports
import { noop } from "lodash";
import { usePathname } from "next/navigation";
import React, { useEffect, useState } from "react";
import { Toaster } from "sonner";
Expand Down Expand Up @@ -58,7 +57,7 @@ export function WizardLayout({
</>
)}
</header>
<Steps maxSteps={maxSteps} currentStep={currentStep} nextStep={noop} />
<Steps maxSteps={maxSteps} currentStep={currentStep} disableNavigation />
</div>
<StepCard>{children}</StepCard>
</div>
Expand Down
Loading