Skip to content

Commit a0b9d8c

Browse files
committed
Do not fail when clicking on the current step
1 parent e463092 commit a0b9d8c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/common/src/wizard/reducer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ const handleNext = (state, nextStep, formOptions, fields) => {
6565
export const findCurrentStep = (activeStep, fields) => fields.find(({ name }) => name === activeStep);
6666

6767
const jumpToStep = (state, index, valid, fields, crossroads, formOptions) => {
68+
if (index === state.activeStepIndex) {
69+
return state;
70+
}
71+
6872
const clickOnPreviousStep = state.prevSteps[index];
6973

7074
if (clickOnPreviousStep) {

packages/pf4-component-mapper/src/tests/wizard/wizard.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,27 @@ describe('<Wizard />', () => {
413413
expect(wrapper.find(TextInput).props().name).toEqual('bar-field');
414414
});
415415

416+
it('should not fail when click on the first step', async () => {
417+
await act(async () => {
418+
wrapper = mount(<FormRenderer {...initialProps} />);
419+
});
420+
wrapper.update();
421+
422+
expect(wrapper.find(TextInput).props().name).toEqual('foo-field');
423+
424+
// click on first nav link
425+
await act(async () => {
426+
wrapper
427+
.find('.pf-c-wizard__nav-item')
428+
.first()
429+
.childAt(0)
430+
.simulate('click');
431+
});
432+
wrapper.update();
433+
434+
expect(wrapper.find(TextInput).props().name).toEqual('foo-field');
435+
});
436+
416437
it('should build simple navigation with substeps', () => {
417438
schema = {
418439
fields: [

0 commit comments

Comments
 (0)