@@ -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,26 @@ 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 ;
104-
105- const isInvalidForm = this . checkFormValidity ( this . InfoForm ) ;
106- this . setState ( { firstStepInvalid : isInvalidForm } ) ;
107-
108- const isInvalidForm2 = this . checkFormValidity ( this . AddressForm ) ;
109- this . setState ( { secondStepInvalid : isInvalidForm2 } ) ;
105+ if ( activeStep && this . activeStepIndex === 0 ) {
106+ const isInvalidForm = this . checkFormValidity ( this . InfoForm ) ;
107+ this . setState ( { firstStepInvalid : isInvalidForm } ) ;
108+ }
109+ if ( activeStep && this . activeStepIndex === 1 ) {
110+ const isInvalidForm = this . checkFormValidity ( this . AddressForm ) ;
111+ this . setState ( { secondStepInvalid : isInvalidForm } ) ;
112+ }
110113 }
111114
112115 private checkFormValidity ( form : any ) {
@@ -126,7 +129,10 @@ export default class LinearStepper extends React.Component<any, any> {
126129 }
127130
128131 private get activeStep ( ) : IgrStep | undefined {
129- return this . stepperRef . current . steps . find ( ( step : IgrStep ) => step . active ) ;
132+ return this . stepperRef . current . steps . find ( ( step : IgrStep , index : number ) => {
133+ this . activeStepIndex = index ;
134+ return step . active ;
135+ } ) ;
130136 }
131137}
132138
0 commit comments