diff --git a/packages/block-editor/src/components/content-only-controls/index.js b/packages/block-editor/src/components/content-only-controls/index.js index b3f1a8d8b675b3..74e6e7df2d8e50 100644 --- a/packages/block-editor/src/components/content-only-controls/index.js +++ b/packages/block-editor/src/components/content-only-controls/index.js @@ -295,19 +295,13 @@ function BlockFields( { clientId } ) { field.Edit = createConfiguredControl( { control: fieldDef.type, clientId, - updateBlockAttributes, fieldDef, } ); } return field; } ); - }, [ - blockTypeFields, - blockType?.attributes, - clientId, - updateBlockAttributes, - ] ); + }, [ blockTypeFields, blockType?.attributes, clientId ] ); const handleToggleField = ( fieldId ) => { setForm( ( prev ) => { @@ -351,26 +345,7 @@ function BlockFields( { clientId } ) { fields={ dataFormFields } form={ form } onChange={ ( changes ) => { - // Map field values to block attributes using field.setValue - const mappedChanges = {}; - Object.entries( changes ).forEach( - ( [ fieldId, fieldValue ] ) => { - const field = dataFormFields.find( - ( f ) => f.id === fieldId - ); - if ( field && field.setValue ) { - const updates = field.setValue( { - item: attributes, - value: fieldValue, - } ); - Object.assign( mappedChanges, updates ); - } else { - // For fields without setValue, use the value directly - mappedChanges[ fieldId ] = fieldValue; - } - } - ); - updateBlockAttributes( clientId, mappedChanges ); + updateBlockAttributes( clientId, changes ); } } /> diff --git a/packages/block-editor/src/components/content-only-controls/link/index.js b/packages/block-editor/src/components/content-only-controls/link/index.js index b7af677f3e4d64..fd25efcf99b1db 100644 --- a/packages/block-editor/src/components/content-only-controls/link/index.js +++ b/packages/block-editor/src/components/content-only-controls/link/index.js @@ -67,15 +67,15 @@ export function getUpdatedLinkAttributes( { }; } -export default function Link( { data, field, config = {} } ) { +export default function Link( { data, field, onChange, config = {} } ) { const [ isLinkControlOpen, setIsLinkControlOpen ] = useState( false ); const { popoverProps } = useInspectorPopoverPlacement( { isControl: true, } ); - const { clientId, updateBlockAttributes, fieldDef } = config; + const { fieldDef } = config; const updateAttributes = ( newValue ) => { const mappedChanges = field.setValue( { item: data, value: newValue } ); - updateBlockAttributes( clientId, mappedChanges ); + onChange( mappedChanges ); }; const value = field.getValue( { item: data } ); diff --git a/packages/block-editor/src/components/content-only-controls/media/index.js b/packages/block-editor/src/components/content-only-controls/media/index.js index c8531b26c4a478..647ba3649c51b5 100644 --- a/packages/block-editor/src/components/content-only-controls/media/index.js +++ b/packages/block-editor/src/components/content-only-controls/media/index.js @@ -83,19 +83,19 @@ function MediaThumbnail( { data, field, attachment } ) { return ; } -export default function Media( { data, field, config = {} } ) { +export default function Media( { data, field, onChange, config = {} } ) { const { popoverProps } = useInspectorPopoverPlacement( { isControl: true, } ); const value = field.getValue( { item: data } ); const { allowedTypes = [], multiple = false } = field.config || {}; - const { clientId, updateBlockAttributes, fieldDef } = config; + const { fieldDef } = config; const updateAttributes = ( newFieldValue ) => { const mappedChanges = field.setValue( { item: data, value: newFieldValue, } ); - updateBlockAttributes( clientId, mappedChanges ); + onChange( mappedChanges ); }; // Check if featured image is supported by checking if it's in the mapping diff --git a/packages/block-editor/src/components/content-only-controls/rich-text/index.js b/packages/block-editor/src/components/content-only-controls/rich-text/index.js index 9c5dec389e845d..62d9e22e31572d 100644 --- a/packages/block-editor/src/components/content-only-controls/rich-text/index.js +++ b/packages/block-editor/src/components/content-only-controls/rich-text/index.js @@ -23,15 +23,16 @@ export default function RichTextControl( { data, field, hideLabelFromVision, + onChange, config = {}, } ) { const registry = useRegistry(); const attrValue = field.getValue( { item: data } ); const fieldConfig = field.config || {}; - const { clientId, updateBlockAttributes } = config; + const { clientId } = config; const updateAttributes = ( html ) => { const mappedChanges = field.setValue( { item: data, value: html } ); - updateBlockAttributes( clientId, mappedChanges ); + onChange( mappedChanges ); }; const [ selection, setSelection ] = useState( { start: undefined, diff --git a/packages/block-library/src/cover/index.js b/packages/block-library/src/cover/index.js index 1f7c6ac4edbeb9..4eb1fe0901120b 100644 --- a/packages/block-library/src/cover/index.js +++ b/packages/block-library/src/cover/index.js @@ -78,7 +78,7 @@ if ( window.__experimentalContentOnlyPatternInsertion ) { }, ]; settings[ formKey ] = { - fields: [ 'content' ], + fields: [ 'background' ], }; }