diff --git a/src/components/stepforms/RenameStepForm.vue b/src/components/stepforms/RenameStepForm.vue index 4d0b3bccb2..a5025e03f8 100644 --- a/src/components/stepforms/RenameStepForm.vue +++ b/src/components/stepforms/RenameStepForm.vue @@ -54,7 +54,9 @@ export default class RenameStepForm extends BaseStepForm { submit() { this.$$super.submit(); - this.setSelectedColumns({ column: this.editedStep.newname }); + if (this.errors === null) { + this.setSelectedColumns({ column: this.editedStep.newname }); + } } } diff --git a/tests/unit/rename-step-form.spec.ts b/tests/unit/rename-step-form.spec.ts index b8e6d6a212..14a4e13139 100644 --- a/tests/unit/rename-step-form.spec.ts +++ b/tests/unit/rename-step-form.spec.ts @@ -153,4 +153,18 @@ describe('Rename Step Form', () => { wrapper.find('.widget-form-action__button--validate').trigger('click'); expect(store.state.selectedColumns).to.eql(['toto']); }); + + it('should not change the column focus if validation fails', () => { + const store = setupStore({ + dataset: { + headers: [{ name: 'columnA' }, { name: 'columnB' }, { name: 'columnC' }], + data: [], + }, + selectedColumns: ['columnA'], + }); + const wrapper = mount(RenameStepForm, { store, localVue }); + wrapper.setData({ editedStep: { name: 'rename', oldname: 'columnA', newname: 'columnB' } }); + wrapper.find('.widget-form-action__button--validate').trigger('click'); + expect(store.state.selectedColumns).to.eql(['columnA']); + }); });