Skip to content

Commit 6cd1924

Browse files
authored
Merge pull request #480 from IgniteUI/bpachilova/stepper-samples-fixes
Stepper samples fixes
2 parents 6fbacf5 + 4233746 commit 6cd1924

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

samples/layouts/stepper/animations/src/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import ReactDOM from 'react-dom/client';
33
import './index.css';
44
import {
55
IgrStepper, IgrStep, IgrStepperModule, IgrRadio, IgrRadioGroup, IgrRadioModule, IgrRadioGroupModule,
6-
IgrButton, IgrButtonModule, IgrInput, IgrInputModule, IgrSelect, IgrSelectItem, IgrSelectModule, IgrDropdown,
7-
IgrDropdownItemComponentEventArgs, IgrComponentValueChangedEventArgs
6+
IgrButton, IgrButtonModule, IgrInput, IgrInputModule, IgrSelect, IgrSelectItem, IgrSelectModule,
7+
IgrSelectItemComponentEventArgs, IgrComponentValueChangedEventArgs
88
} from 'igniteui-react';
99
import 'igniteui-webcomponents/themes/light/bootstrap.css';
1010

@@ -93,15 +93,15 @@ export default class StepperAnimations extends React.Component<any, any> {
9393
);
9494
}
9595

96-
public orientationChange(s: IgrDropdown, e: IgrDropdownItemComponentEventArgs){
96+
public orientationChange(s: IgrSelect, e: IgrSelectItemComponentEventArgs){
9797
const selectedValue = e.detail.value;
9898
this.setState({orientation: selectedValue});
9999
}
100-
public horizontalAnimationChange(s: IgrDropdown, e: IgrDropdownItemComponentEventArgs){
100+
public horizontalAnimationChange(s: IgrSelect, e: IgrSelectItemComponentEventArgs){
101101
const selectedValue = e.detail.value;
102102
this.setState({horizontalAnimation: selectedValue});
103103
}
104-
public verticalAnimationChange(s: IgrDropdown, e: IgrDropdownItemComponentEventArgs){
104+
public verticalAnimationChange(s: IgrSelect, e: IgrSelectItemComponentEventArgs){
105105
const selectedValue = e.detail.value;
106106
this.setState({verticalAnimation: selectedValue});
107107
}

samples/layouts/stepper/linear/src/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)