diff --git a/assets/js/src/form_editor/blocks/custom_text/custom_field_settings.jsx b/assets/js/src/form_editor/blocks/custom_text/custom_field_settings.jsx index 193eb61ebb..16b9590c88 100644 --- a/assets/js/src/form_editor/blocks/custom_text/custom_field_settings.jsx +++ b/assets/js/src/form_editor/blocks/custom_text/custom_field_settings.jsx @@ -6,39 +6,24 @@ import { } from '@wordpress/components'; import PropTypes from 'prop-types'; import MailPoet from 'mailpoet'; -import { useDispatch, useSelect } from '@wordpress/data'; const CustomFieldSettings = ({ mandatory, validate, - customFieldId, - updateAttributes, + isSaving, + onSave, }) => { const [localMandatory, setLocalMandatory] = useState(mandatory); const [localValidate, setLocalValidate] = useState(validate); - const { saveCustomField } = useDispatch('mailpoet-form-editor'); - const isSaving = useSelect( - (sel) => sel('mailpoet-form-editor').getIsCustomFieldSaving(), - [] - ); return ( <> - - - { + const isSaving = useSelect( + (sel) => sel('mailpoet-form-editor').getIsCustomFieldSaving(), + [] + ); + const { saveCustomField } = useDispatch('mailpoet-form-editor'); const inspectorControls = ( (setAttributes(attrs))} - customFieldId={attributes.customFieldId} mandatory={attributes.mandatory} validate={attributes.validate} + isSaving={isSaving} + onSave={(params) => saveCustomField({ + customFieldId: attributes.customFieldId, + data: { + params: { + required: params.mandatory ? '1' : undefined, + validate: params.validate, + lines: params.lines, + }, + }, + onFinish: () => setAttributes({ + mandatory: params.mandatory, + validate: params.validate, + lines: params.lines, + }), + })} /> @@ -39,7 +59,6 @@ const CustomTextAreaEdit = ({ attributes, setAttributes }) => { /> - );