Skip to content

Commit a1990ae

Browse files
Areg HakobyanAreg Hakobyan
authored andcommitted
fix(Steps): successed steps behavior and stories logic
1 parent ae21ae2 commit a1990ae

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/components/molecules/Steps/Step.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const Step: FC<IStepProps> = (props) => {
130130
className={classNames("steps__step", {
131131
steps__step_disabled: disabled && !error && !loading,
132132
steps__step_error: error,
133-
steps__step_success: complete && state !== "next",
133+
steps__step_success: complete,
134134
steps__step_current: state === "current"
135135
})}
136136
>

src/components/molecules/Steps/Steps.stories.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ const StepsWizardTemplate: FC<IStepsProps> = (props) => {
166166
.filter((item) => item !== null);
167167

168168
const isStepEnabled = () =>
169-
stepsData.map((item, index) =>
170-
item.touched || stepsData[index - 1]?.touched || stepsData[index - 1]?.complete || index === 0
171-
? index
172-
: null
173-
);
169+
stepsData.map((item, index) => (item.touched || stepsData[index - 1]?.complete || index === 0 ? index : null));
174170

175171
return (
176172
<>
@@ -191,7 +187,8 @@ const StepsWizardTemplate: FC<IStepsProps> = (props) => {
191187
onClick: nextButtonHandler,
192188
disabled:
193189
(!isStepEnabled().includes(currentStep + 1) && !isLastStep) ||
194-
(isLastStep && getErrorStepIndices().length > 0)
190+
(isLastStep && getErrorStepIndices().length > 0) ||
191+
(isLastStep && !stepsData[stepsData.length - 1].complete)
195192
}
196193
]}
197194
footerContent={
@@ -210,7 +207,7 @@ const StepsWizardTemplate: FC<IStepsProps> = (props) => {
210207
label={step.label}
211208
description={step.description}
212209
disabled={!isStepEnabled().includes(index)}
213-
error={getErrorStepIndices().includes(index) && index !== stepsData.length - 1}
210+
error={getErrorStepIndices().includes(index)}
214211
complete={step.complete}
215212
/>
216213
);

0 commit comments

Comments
 (0)