diff --git a/packages/dnb-eufemia/src/components/step-indicator/StepIndicatorContext.tsx b/packages/dnb-eufemia/src/components/step-indicator/StepIndicatorContext.tsx index b1ea7697487..89cc7a7647b 100644 --- a/packages/dnb-eufemia/src/components/step-indicator/StepIndicatorContext.tsx +++ b/packages/dnb-eufemia/src/components/step-indicator/StepIndicatorContext.tsx @@ -145,7 +145,7 @@ export function StepIndicatorProvider({ const currentStepFromProps = getActiveStepFromProps() if (currentStepFromProps !== activeStep) { - setActiveStep(props.current_step) + setActiveStep(currentStepFromProps) } }, [props.current_step, data]) diff --git a/packages/dnb-eufemia/src/components/step-indicator/__tests__/StepIndicator.test.tsx b/packages/dnb-eufemia/src/components/step-indicator/__tests__/StepIndicator.test.tsx index 8fcc083cc81..a4fb8a51731 100644 --- a/packages/dnb-eufemia/src/components/step-indicator/__tests__/StepIndicator.test.tsx +++ b/packages/dnb-eufemia/src/components/step-indicator/__tests__/StepIndicator.test.tsx @@ -414,6 +414,60 @@ describe('StepIndicator in loose mode', () => { ).toBeInTheDocument() }) + it('should react on is_current data prop change', () => { + const TestComp = (props) => { + return ( + <> + + + + ) + } + + const data1 = [ + { + title: 'Step A', + }, + { + title: 'Step B', + }, + { + title: 'Step C', + is_current: true, + }, + ] + + const { rerender } = render() + expect( + document.querySelector('li.dnb-step-indicator__item--current') + .textContent + ).toContain('3.Step CSteg 3 av 3') + + const data2 = [ + { + title: 'Step A', + }, + { + title: 'Step B', + is_current: true, + }, + { + title: 'Step C', + }, + ] + + rerender() + + expect( + document.querySelector('li.dnb-step-indicator__item--current') + .textContent + ).toContain('2.Step BSteg 2 av 3') + }) + it('should react on current_step prop change', () => { const TestComp = ({ id, ...props }) => { return (