diff --git a/assets/js/src/form_editor/store/controls.jsx b/assets/js/src/form_editor/store/controls.jsx index 5a566b0231..119a16e9d2 100644 --- a/assets/js/src/form_editor/store/controls.jsx +++ b/assets/js/src/form_editor/store/controls.jsx @@ -47,15 +47,18 @@ export default { endpoint: 'customFields', action: 'save', data: requestData, - }).done((response) => { - dispatch('mailpoet-form-editor').saveCustomFieldDone(customField.id, response.data); - if (typeof actionData.onFinish === 'function') actionData.onFinish(); - }).fail((response) => { - let errorMessage = null; - if (response.errors.length > 0) { - errorMessage = response.errors.map((error) => (error.message)); - } - dispatch('mailpoet-form-editor').saveCustomFieldFailed(errorMessage); - }); + }) + .then((response) => { + dispatch('mailpoet-form-editor').saveCustomFieldDone(customField.id, response.data); + if (typeof actionData.onFinish === 'function') actionData.onFinish(); + }) + .then(dispatch('mailpoet-form-editor').saveForm) + .fail((response) => { + let errorMessage = null; + if (response.errors.length > 0) { + errorMessage = response.errors.map((error) => (error.message)); + } + dispatch('mailpoet-form-editor').saveCustomFieldFailed(errorMessage); + }); }, }; diff --git a/assets/js/src/form_editor/store/reducers/save_custom_field_done.jsx b/assets/js/src/form_editor/store/reducers/save_custom_field_done.jsx index 094f1d1a1a..5e5b31b496 100644 --- a/assets/js/src/form_editor/store/reducers/save_custom_field_done.jsx +++ b/assets/js/src/form_editor/store/reducers/save_custom_field_done.jsx @@ -19,7 +19,6 @@ export default (state, action) => { return { ...state, isCustomFieldSaving: false, - isFormSaving: false, notices, customFields, }; diff --git a/assets/js/src/form_editor/store/reducers/save_custom_field_failed.jsx b/assets/js/src/form_editor/store/reducers/save_custom_field_failed.jsx index 87f40a56ad..1041e4d359 100644 --- a/assets/js/src/form_editor/store/reducers/save_custom_field_failed.jsx +++ b/assets/js/src/form_editor/store/reducers/save_custom_field_failed.jsx @@ -8,7 +8,6 @@ export default (state, action) => { }); return { ...state, - isFormSaving: false, isCustomFieldSaving: false, notices, }; diff --git a/assets/js/src/form_editor/store/reducers/save_custom_field_started.jsx b/assets/js/src/form_editor/store/reducers/save_custom_field_started.jsx index c5082e7e2b..9bb08a9a68 100644 --- a/assets/js/src/form_editor/store/reducers/save_custom_field_started.jsx +++ b/assets/js/src/form_editor/store/reducers/save_custom_field_started.jsx @@ -2,7 +2,6 @@ export default (state) => { const notices = state.notices.filter((notice) => notice.id !== 'custom-field'); return { ...state, - isFormSaving: true, isCustomFieldSaving: true, notices, };