Skip to content

Comments

fix: clicking on previous step navigates to correct step instead of next#22146

Merged
anikdhabal merged 17 commits intocalcom:mainfrom
subediDarshan:fix/step-indicator-navigation
Sep 4, 2025
Merged

fix: clicking on previous step navigates to correct step instead of next#22146
anikdhabal merged 17 commits intocalcom:mainfrom
subediDarshan:fix/step-indicator-navigation

Conversation

@subediDarshan
Copy link
Contributor

@subediDarshan subediDarshan commented Jun 30, 2025

What does this PR do?

This PR ensures that when a user clicks on a previous step's progress bar segment (white bar), they are navigated to that specific step, rather than the next step. This aligns with expected user behavior.

Visual Demo

Before:

Bug-Capture-qyF3Ypn8-wNKkCV3jrjEGbZKBCTI8Xg2iuVoDxqxh0Ew.mp4

After:

Untitled.video.-.Made.with.Clipchamp.1.mp4

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. (N/A here)
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Run app locally
  • Navigate to http://localhost:3000/getting-started/connected-video.
  • Click on a white progress bar segment representing a previous step (eg: step 2 or 3).
  • Confirm that you are taken to the correct step, not the next one.

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

Summary by cubic

Clicking on a previous step in the progress bar now takes users to that exact step, instead of moving them to the next step. This makes navigation match what users expect.

@subediDarshan subediDarshan requested review from a team as code owners June 30, 2025 08:08
@vercel
Copy link

vercel bot commented Jun 30, 2025

@subediDarshan is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant
Copy link

CLAassistant commented Jun 30, 2025

CLA assistant check
All committers have signed the CLA.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jun 30, 2025
@github-actions github-actions bot added ui area: UI, frontend, button, form, input 🐛 bug Something isn't working labels Jun 30, 2025
@graphite-app
Copy link

graphite-app bot commented Jun 30, 2025

Graphite Automations

"Add community label" took an action on this PR • (06/30/25)

1 label was added to this PR based on Keith Williams's automation.

"Add ready-for-e2e label" took an action on this PR • (07/09/25)

1 label was added to this PR based on Keith Williams's automation.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 2 issues across 5 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

Copy link
Contributor

@Devanshusharma2005 Devanshusharma2005 left a comment

Choose a reason for hiding this comment

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

Hey @subediDarshan thanks for the pr , can you please fix the issues suggested by cubic. and also can you make a loom for making sure that the steps only go to previous adjacent one or any step in the previous ?

kart1ka
kart1ka previously approved these changes Jun 30, 2025
Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

LGTM

@subediDarshan
Copy link
Contributor Author

subediDarshan commented Jul 1, 2025

Hey @Devanshusharma2005
I have addressed issues suggested by cubic.
And here's the video demo showing steps only go to previous adjacent one or any step in the previous and not to the upcoming ones:

pr-3.mp4

kart1ka
kart1ka previously approved these changes Jul 1, 2025
Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

LGTM

@anikdhabal anikdhabal added the Low priority Created by Linear-GitHub Sync label Jul 4, 2025
sean-brydon
sean-brydon previously approved these changes Jul 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jul 9, 2025

E2E results are ready!

@anikdhabal
Copy link
Contributor

@subediDarshan pls fix the conflicts

@subediDarshan subediDarshan dismissed stale reviews from sean-brydon and kart1ka via b3c3878 July 10, 2025 13:07
const goToStep = useCallback(
(newStep: number) => {
setStep(Math.min(Math.max(newStep, 1), maxSteps));
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

kart1ka
kart1ka previously approved these changes Jul 10, 2025
Copy link
Contributor

@kart1ka kart1ka left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the PR.

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.

@github-actions
Copy link
Contributor

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Jul 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Replaces step navigation callback from nextStep to navigateToStep(step: number) across the wizard and onboarding flows. Steps component types and click handler were updated to call navigateToStep with the clicked index. OnboardingPage and WizardForm now pass a goToStep function to Steps. useWizardState.goToStep was adjusted to convert a zero-based input to a one-based clamped step. WizardLayout removes nextStep={noop} and uses disableNavigation. Tests updated to match the new prop name.

Assessment against linked issues

Objective Addressed Explanation
Fix click on previous step indicator to navigate to the selected step instead of advancing to next (#22140)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Replace nextStep={noop} with disableNavigation and remove noop import (packages/ui/components/layout/WizardLayout.tsx) This changes how WizardLayout disables navigation UI rather than fixing the click-target bug; it’s a UI/prop-shape change not required by the linked issue.
Rename prop in tests from nextStep to navigateToStep (packages/ui/components/form/step/steps.test.tsx) Test updates are ancillary to the bug fix and do not affect the functional behavior being targeted; they are maintenance rather than required change.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c316721 and f8203f7.

📒 Files selected for processing (7)
  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (2 hunks)
  • packages/app-store/googlecalendar/lib/CalendarService.ts (1 hunks)
  • packages/ui/components/form/step/Steps.tsx (3 hunks)
  • packages/ui/components/form/step/steps.test.tsx (1 hunks)
  • packages/ui/components/form/wizard/WizardForm.tsx (2 hunks)
  • packages/ui/components/form/wizard/useWizardState.ts (1 hunks)
  • packages/ui/components/layout/WizardLayout.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.

Files:

  • packages/ui/components/layout/WizardLayout.tsx
  • packages/ui/components/form/step/steps.test.tsx
  • packages/ui/components/form/wizard/useWizardState.ts
  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx
  • packages/ui/components/form/wizard/WizardForm.tsx
  • packages/app-store/googlecalendar/lib/CalendarService.ts
  • packages/ui/components/form/step/Steps.tsx
🧠 Learnings (4)
packages/ui/components/form/wizard/useWizardState.ts (1)

Learnt from: alishaz-polymath
PR: #22304
File: packages/features/eventtypes/components/MultiplePrivateLinksController.tsx:92-94
Timestamp: 2025-07-16T06:42:27.024Z
Learning: In the MultiplePrivateLinksController component (packages/features/eventtypes/components/MultiplePrivateLinksController.tsx), the currentLink.maxUsageCount ?? 1 fallback in the openSettingsDialog function is intentional. Missing maxUsageCount values indicate old/legacy private links that existed before the expiration feature was added, and they should default to single-use behavior (1) for backward compatibility.

apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

Learnt from: Anshumancanrock
PR: #22570
File: apps/web/modules/signup-view.tsx:253-253
Timestamp: 2025-07-21T21:33:23.371Z
Learning: In signup-view.tsx, when checking if redirectUrl contains certain strings, using explicit && checks (redirectUrl && redirectUrl.includes()) is preferred over optional chaining (redirectUrl?.includes()) to ensure the result is always a boolean rather than potentially undefined. This approach provides cleaner boolean contracts for downstream conditional logic.

packages/ui/components/form/wizard/WizardForm.tsx (1)

Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.

packages/app-store/googlecalendar/lib/CalendarService.ts (1)

Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-21T13:54:11.770Z
Learning: Applies to **/*.{js,jsx,ts,tsx} : Flag excessive Day.js use in performance-critical code. Functions like .add, .diff, .isBefore, and .isAfter are slow, especially in timezone mode. Prefer .utc() for better performance. Where possible, replace with native Date and direct .valueOf() comparisons for faster execution. Recommend using native methods or Day.js .utc() consistently in hot paths like loops.

🧬 Code Graph Analysis (1)
packages/ui/components/form/wizard/WizardForm.tsx (1)
packages/ui/components/form/wizard/useWizardState.ts (1)
  • useWizardState (22-55)
🔇 Additional comments (10)
packages/ui/components/form/step/steps.test.tsx (1)

16-16: LGTM! Test prop updated to match component interface.

The prop rename from nextStep to navigateToStep correctly aligns with the component interface changes while maintaining the same test coverage.

packages/ui/components/layout/WizardLayout.tsx (1)

60-60: LGTM! Using disableNavigation is cleaner than noop functions.

Explicitly disabling navigation is more intentional and readable than passing a no-operation function. This change aligns well with the component's purpose in the wizard layout.

packages/ui/components/form/wizard/useWizardState.ts (1)

28-29: LGTM! Index conversion is correctly implemented.

The conversion from 0-based component interface to 1-based URL parameters is properly handled with appropriate bounds checking. The added comment clearly explains the conversion logic.

apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

167-167: LGTM! Navigation prop correctly updated.

The change from nextStep to navigateToStep with the new goToStep function properly enables navigation to any previous step, which aligns with the PR objective of fixing the navigation behavior.

packages/ui/components/form/wizard/WizardForm.tsx (2)

49-49: LGTM! Correctly extracting goToStep for navigation.

Adding goToStep to the destructured return enables the step navigation functionality that was previously unused.


74-74: LGTM! Navigation prop updated consistently with the refactor.

The change from nextStep to navigateToStep with goToStep function enables direct navigation to any step, which aligns with the PR objective and the broader refactor pattern across the codebase.

packages/ui/components/form/step/Steps.tsx (4)

6-6: LGTM - Type definition correctly updated.

The function signature change from nextStep to navigateToStep: (step: number) => void properly supports navigation to any step by index, aligning with the PR objective.


14-14: LGTM - Maintains type safety for disabled navigation.

The optional undefined type correctly excludes navigation functionality when disableNavigation is true.


26-26: LGTM - Prop destructuring updated consistently.

The prop name change from nextStep to navigateToStep is consistent with the type definition updates.


38-38: LGTM - Click handler correctly passes step index.

The navigation logic now correctly passes the clicked step's index to navigateToStep. This fixes the issue described in the PR where clicking previous steps would navigate to the next step instead.

Note: The handler passes zero-based indices - ensure consuming components handle this correctly.

@github-actions github-actions bot removed the Stale label Jul 26, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

127-132: Bounds-check and ignore redundant navigation in goToStep (repeat from earlier review).

Without bounds checking, an out-of-range step leads to newStep being undefined and stepTransform(newStep) falling back to INITIAL_STEP. Also, clicking the current step should no-op to avoid a needless route push.

Apply this diff:

-  const goToStep = (step: number) => {
-    const newStep = steps[step];
-    startTransition(() => {
-      router.push(`/getting-started/${stepTransform(newStep)}`);
-    });
-  };
+  const goToStep = (step: number) => {
+    // Guard against invalid or redundant indices
+    if (step < 0 || step >= steps.length || step === currentStepIndex) return;
+    const newStep = steps[step];
+    startTransition(() => {
+      router.push(`/getting-started/${stepTransform(newStep)}`);
+    });
+  };
🧹 Nitpick comments (1)
apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

157-159: Localize fallback text for missing title.

Per guidelines, avoid hardcoded UI strings. Use t() for the fallback.

-                  {headers[currentStepIndex]?.title || "Undefined title"}
+                  {headers[currentStepIndex]?.title || t("undefined_title", "Undefined title")}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8203f7 and 197db24.

📒 Files selected for processing (1)
  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

167-167: Index alignment verified – no changes required

Verified that the Steps component passes a 0-based index to navigateToStep, which aligns with the 0-based indexing expected by goToStep. The current implementation is correct.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

128-133: Harden goToStep: clamp index and avoid redundant navigation

Cheap defensive guard to prevent OOB access and unnecessary route pushes.

-  const goToStep = (step: number) => {
-    const newStep = steps[step];
-    startTransition(() => {
-      router.push(`/getting-started/${stepTransform(newStep)}`);
-    });
-  };
+  const goToStep = (step: number) => {
+    const clamped = Math.max(0, Math.min(step, steps.length - 1));
+    if (clamped === currentStepIndex) return;
+    const newStep = steps[clamped];
+    if (!newStep) return; // defensive
+    startTransition(() => {
+      router.push(`/getting-started/${stepTransform(newStep)}`);
+    });
+  };

Run to confirm the index base used by Steps.navigateToStep across the repo (0-based vs 1-based); adjust by step - 1 if needed:

#!/bin/bash
# Inspect Steps props/usage
rg -nP -C3 '\bnavigateToStep\b' --type=ts --type=tsx
rg -nP -C3 '\bcurrentStep\b.*\{|\bmaxSteps\b.*\{' --type=ts --type=tsx
# Try to locate Steps component definition
fd -t f -a 'Steps.tsx' | xargs -I{} rg -nP -C3 'navigateToStep|currentStep|maxSteps' {}
🧹 Nitpick comments (1)
apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (1)

169-169: Steps wiring looks correct; verify index base and fix nearby i18n nit

  • currentStep is 1-based; confirm navigateToStep receives a 0-based index from Steps to avoid off-by-one.

Optional i18n tidy (outside this hunk): replace hardcoded “Undefined title” with a localized fallback.

-                  {headers[currentStepIndex]?.title || "Undefined title"}
+                  {headers[currentStepIndex]?.title || t("undefined_title")}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 197db24 and b1ade67.

📒 Files selected for processing (1)
  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/modules/getting-started/[[...step]]/onboarding-view.tsx

@anikdhabal anikdhabal enabled auto-merge (squash) September 4, 2025 04:13
@anikdhabal anikdhabal merged commit 0fadbe1 into calcom:main Sep 4, 2025
32 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync Low priority Created by Linear-GitHub Sync ready-for-e2e size/M ui area: UI, frontend, button, form, input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Clicking on previous step indicator navigates to next step instead of selected step

7 participants