diff --git a/CommonUI/src/Components/Forms/BasicForm.tsx b/CommonUI/src/Components/Forms/BasicForm.tsx index 4f5b2257b75..6f52fd115f8 100644 --- a/CommonUI/src/Components/Forms/BasicForm.tsx +++ b/CommonUI/src/Components/Forms/BasicForm.tsx @@ -288,22 +288,25 @@ const BasicForm: ForwardRefExoticComponent = forwardRef( props.onSubmit(values); } else if (props.steps && props.steps.length > 0) { - const currentStepIndex: number = props.steps.findIndex( + const steps: Array> = props.steps.filter( + (step: FormStep) => { + if (!step.showIf) { + return true; + } + + return step.showIf(refCurrentValue.current); + } + ); + + const currentStepIndex: number = steps.findIndex( (step: FormStep) => { return step.id === currentFormStepId; } ); + if (currentStepIndex > -1) { setCurrentFormStepId( - ( - props.steps.filter((step: FormStep) => { - if (!step.showIf) { - return true; - } - - return step.showIf(refCurrentValue.current); - })[currentStepIndex + 1] as FormStep - ).id + (steps[currentStepIndex + 1] as FormStep).id ); } } diff --git a/CommonUI/src/Components/Forms/Steps/Steps.tsx b/CommonUI/src/Components/Forms/Steps/Steps.tsx index ca11b762a35..b0f1fceb494 100644 --- a/CommonUI/src/Components/Forms/Steps/Steps.tsx +++ b/CommonUI/src/Components/Forms/Steps/Steps.tsx @@ -13,45 +13,48 @@ export interface ComponentProps { const Steps: Function = ( props: ComponentProps ): ReactElement => { + const steps: Array> = props.steps.filter( + (step: FormStep) => { + if (!step.showIf) { + return true; + } + + return step.showIf(props.formValues); + } + ); + return (