File tree Expand file tree Collapse file tree
docs/data/material/components/steppers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,11 @@ export default function VerticalLinearStepper() {
5454 const previousActiveStep = previousActiveStepRef . current ;
5555 previousActiveStepRef . current = activeStep ;
5656
57+ // Skip the initial render.
58+ if ( previousActiveStep === activeStep ) {
59+ return ;
60+ }
61+
5762 if ( previousActiveStep < activeStep ) {
5863 if ( activeStep === steps . length ) {
5964 // If the user has completed all steps and hits Finish, focus the Reset button.
@@ -64,8 +69,8 @@ export default function VerticalLinearStepper() {
6469 }
6570 return ;
6671 }
67- if ( activeStep === 0 ) {
68- // If the user has completed all steps and hits Reset, focus the Next button.
72+ if ( activeStep === 0 && previousActiveStep === steps . length ) {
73+ // If the user has completed all steps and hits Reset, focus the Continue button.
6974 continueButtonRef . current ?. focus ( ) ;
7075 } else {
7176 // Focus the "Back" button if the user is going backward.
@@ -98,14 +103,15 @@ export default function VerticalLinearStepper() {
98103 >
99104 { index === steps . length - 1 ? 'Finish' : 'Continue' }
100105 </ Button >
101- < Button
102- disabled = { index === 0 }
103- onClick = { handleBack }
104- sx = { { mt : 1 , mr : 1 } }
105- ref = { backButtonRef }
106- >
107- Back
108- </ Button >
106+ { index !== 0 && (
107+ < Button
108+ onClick = { handleBack }
109+ sx = { { mt : 1 , mr : 1 } }
110+ ref = { backButtonRef }
111+ >
112+ Back
113+ </ Button >
114+ ) }
109115 </ Box >
110116 </ StepContent >
111117 </ Step >
Original file line number Diff line number Diff line change @@ -64,8 +64,8 @@ export default function VerticalLinearStepper() {
6464 }
6565 return ;
6666 }
67- if ( activeStep === 0 ) {
68- // If the user has completed all steps and hits Reset, focus the Next button.
67+ if ( activeStep === 0 && previousActiveStep === steps . length ) {
68+ // If the user has completed all steps and hits Reset, focus the Continue button.
6969 continueButtonRef . current ?. focus ( ) ;
7070 } else {
7171 // Focus the "Back" button if the user is going backward.
You can’t perform that action at this time.
0 commit comments