@@ -19,6 +19,7 @@ export default class LinearStepper extends React.Component<any, any> {
1919 private stepperRef = React . createRef < IgrStepper > ( ) ;
2020 private InfoForm = React . createRef < any > ( ) ;
2121 private AddressForm = React . createRef < any > ( ) ;
22+ private activeStepIndex = 0 ;
2223
2324 constructor ( props : any ) {
2425 super ( props ) ;
@@ -34,7 +35,7 @@ export default class LinearStepper extends React.Component<any, any> {
3435 public render ( ) : JSX . Element {
3536 return (
3637 < div className = "container sample" >
37- < IgrSwitch change = { this . OnSwitchChange } > </ IgrSwitch >
38+ < IgrSwitch change = { this . OnSwitchChange } > < span key = "liner-switch" > Linear </ span > < /IgrSwitch >
3839
3940 < IgrStepper ref = { this . stepperRef } linear = { this . state . linear } >
4041 < IgrStep key = "info-step" invalid = { this . state . linear && this . state . firstStepInvalid } >
@@ -89,24 +90,24 @@ export default class LinearStepper extends React.Component<any, any> {
8990 public OnSwitchChange ( s : IgrCheckboxBase , e : IgrComponentBoolValueChangedEventArgs ) {
9091 this . setState ( { linear : s . checked } ) ;
9192 if ( s . checked ) {
92- this . checkAtiveStepValidity ( ) ;
93+ this . checkActiveStepValidity ( ) ;
9394 }
9495 }
9596
9697 public onInput ( s : IgrInput , e : IgrComponentValueChangedEventArgs ) {
9798 if ( ! this . state . linear ) return ;
9899
99- this . checkAtiveStepValidity ( ) ;
100+ this . checkActiveStepValidity ( ) ;
100101 }
101102
102- private checkAtiveStepValidity ( ) {
103+ private checkActiveStepValidity ( ) {
103104 const activeStep = this . activeStep ;
104105
105- if ( activeStep ?. index === 0 ) {
106+ if ( activeStep && this . activeStepIndex === 0 ) {
106107 const isInvalidForm = this . checkFormValidity ( this . InfoForm ) ;
107108 this . setState ( { firstStepInvalid : isInvalidForm } ) ;
108109 }
109- if ( activeStep ?. index === 1 ) {
110+ if ( activeStep && this . activeStepIndex === 1 ) {
110111 const isInvalidForm = this . checkFormValidity ( this . AddressForm ) ;
111112 this . setState ( { secondStepInvalid : isInvalidForm } ) ;
112113 }
@@ -129,7 +130,10 @@ export default class LinearStepper extends React.Component<any, any> {
129130 }
130131
131132 private get activeStep ( ) : IgrStep | undefined {
132- return this . stepperRef . current . steps . find ( ( step : IgrStep ) => step . active ) ;
133+ return this . stepperRef . current . steps . find ( ( step : IgrStep , index : number ) => {
134+ this . activeStepIndex = index ;
135+ return step . active ;
136+ } ) ;
133137 }
134138}
135139
0 commit comments