-
Notifications
You must be signed in to change notification settings - Fork 12k
fix: clicking on previous step navigates to correct step instead of next #22146
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
Changes from all commits
4934c26
62265a3
30a1ef8
974041f
6c51556
18bfdcc
1eb249f
8af6f95
66a2d4e
f61e200
b3c3878
c999b7e
f8203f7
197db24
b1ade67
a081113
041ae7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| ); | ||
|
|
@@ -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} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason for removal of this props?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In 'Steps' component (where this 'goToStep' function is passed as prop),
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls add a comment in the code mentioning the same
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment added c999b7e |
||
| }, | ||
| [setStep, maxSteps] | ||
| ); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.