From 21f68eec906d1227b35a9881e2dfe574b7ca9e5c Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 9 Jan 2026 11:30:28 +0800 Subject: [PATCH 1/6] Add all fields to the block fields form by default --- packages/block-library/src/audio/index.js | 2 +- packages/block-library/src/button/index.js | 2 +- packages/block-library/src/file/index.js | 2 +- packages/block-library/src/image/index.js | 2 +- packages/block-library/src/media-text/index.js | 2 +- packages/block-library/src/navigation-link/index.js | 2 +- packages/block-library/src/navigation-submenu/index.js | 2 +- packages/block-library/src/pullquote/index.js | 2 +- packages/block-library/src/search/index.js | 2 +- packages/block-library/src/social-link/index.js | 2 +- packages/block-library/src/video/index.js | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/block-library/src/audio/index.js b/packages/block-library/src/audio/index.js index d3bb62a3485884..66c7062692cffa 100644 --- a/packages/block-library/src/audio/index.js +++ b/packages/block-library/src/audio/index.js @@ -58,7 +58,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'audio' ], + fields: [ 'audio', 'caption' ], }; } diff --git a/packages/block-library/src/button/index.js b/packages/block-library/src/button/index.js index 846808023c9248..4bdbde757bb6fb 100644 --- a/packages/block-library/src/button/index.js +++ b/packages/block-library/src/button/index.js @@ -69,7 +69,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'text' ], + fields: [ 'text', 'link' ], }; } diff --git a/packages/block-library/src/file/index.js b/packages/block-library/src/file/index.js index 4257495f0c775f..efe0ae979e3ce9 100644 --- a/packages/block-library/src/file/index.js +++ b/packages/block-library/src/file/index.js @@ -63,7 +63,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'file' ], + fields: [ 'file', 'fileName', 'downloadButtonText' ], }; } diff --git a/packages/block-library/src/image/index.js b/packages/block-library/src/image/index.js index fc65703a23c1f7..e8ee1e3404d7d8 100644 --- a/packages/block-library/src/image/index.js +++ b/packages/block-library/src/image/index.js @@ -106,7 +106,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'image' ], + fields: [ 'image', 'link', 'caption', 'alt' ], }; } diff --git a/packages/block-library/src/media-text/index.js b/packages/block-library/src/media-text/index.js index 1de8b84e64f026..d50e6eaaceb1e6 100644 --- a/packages/block-library/src/media-text/index.js +++ b/packages/block-library/src/media-text/index.js @@ -83,7 +83,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'media' ], + fields: [ 'media', 'link' ], }; } diff --git a/packages/block-library/src/navigation-link/index.js b/packages/block-library/src/navigation-link/index.js index a232f54299f593..1a36a0a9526fcb 100644 --- a/packages/block-library/src/navigation-link/index.js +++ b/packages/block-library/src/navigation-link/index.js @@ -112,7 +112,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'label' ], + fields: [ 'label', 'link' ], }; } diff --git a/packages/block-library/src/navigation-submenu/index.js b/packages/block-library/src/navigation-submenu/index.js index 046f959c7223f3..82cf8a6124a3ff 100644 --- a/packages/block-library/src/navigation-submenu/index.js +++ b/packages/block-library/src/navigation-submenu/index.js @@ -71,7 +71,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'label' ], + fields: [ 'label', 'link' ], }; } diff --git a/packages/block-library/src/pullquote/index.js b/packages/block-library/src/pullquote/index.js index 764946b3fc20a2..bd6bcf7cc3dc99 100644 --- a/packages/block-library/src/pullquote/index.js +++ b/packages/block-library/src/pullquote/index.js @@ -54,7 +54,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'value' ], + fields: [ 'value', 'citation' ], }; } diff --git a/packages/block-library/src/search/index.js b/packages/block-library/src/search/index.js index 983f1706a21625..265f2bb119d8df 100644 --- a/packages/block-library/src/search/index.js +++ b/packages/block-library/src/search/index.js @@ -50,7 +50,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'label' ], + fields: [ 'label', 'buttonText', 'placeholder' ], }; } diff --git a/packages/block-library/src/social-link/index.js b/packages/block-library/src/social-link/index.js index 67e98a10b64669..250191d91c7cef 100644 --- a/packages/block-library/src/social-link/index.js +++ b/packages/block-library/src/social-link/index.js @@ -44,7 +44,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'link' ], + fields: [ 'link', 'label' ], }; } diff --git a/packages/block-library/src/video/index.js b/packages/block-library/src/video/index.js index 3a275c91eaca37..37a1907086d53e 100644 --- a/packages/block-library/src/video/index.js +++ b/packages/block-library/src/video/index.js @@ -61,7 +61,7 @@ if ( window.__experimentalContentOnlyInspectorFields ) { }, ]; settings[ formKey ] = { - fields: [ 'video' ], + fields: [ 'video', 'caption' ], }; } From a81afb8f93b6ea9574098ee5aa7626c538499a99 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 9 Jan 2026 16:11:41 +0800 Subject: [PATCH 2/6] Adjust appearance in patterns, only show first field and use a non-block title for standalone blocks --- .../src/hooks/block-fields/index.js | 54 ++++++++++++++----- .../src/hooks/block-fields/styles.scss | 1 + 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/packages/block-editor/src/hooks/block-fields/index.js b/packages/block-editor/src/hooks/block-fields/index.js index b086b483d5573c..951e1d9e8012f2 100644 --- a/packages/block-editor/src/hooks/block-fields/index.js +++ b/packages/block-editor/src/hooks/block-fields/index.js @@ -10,6 +10,7 @@ import { import { createHigherOrderComponent } from '@wordpress/compose'; import { DataForm } from '@wordpress/dataviews'; import { useContext, useState, useMemo } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; /** * Internal dependencies @@ -169,7 +170,13 @@ function denormalizeLinkValue( value, fieldDef ) { return result; } -function BlockFields( { clientId, blockType, attributes, setAttributes } ) { +function BlockFields( { + clientId, + blockType, + attributes, + setAttributes, + isCollapsed = false, +} ) { const blockTitle = useBlockDisplayTitle( { clientId, context: 'list-view', @@ -178,9 +185,19 @@ function BlockFields( { clientId, blockType, attributes, setAttributes } ) { const blockTypeFields = blockType?.[ fieldsKey ]; - const [ form, setForm ] = useState( () => { - return blockType?.[ formKey ]; - } ); + const computedForm = useMemo( () => { + if ( ! isCollapsed ) { + return blockType?.[ formKey ]; + } + + // For a collapsed form only show the first field by default. + return { + ...blockType?.[ formKey ], + fields: [ blockType?.[ formKey ]?.fields?.[ 0 ] ], + }; + }, [ blockType, isCollapsed ] ); + + const [ form, setForm ] = useState( computedForm ); // Build DataForm fields with proper structure const dataFormFields = useMemo( () => { @@ -310,16 +327,24 @@ function BlockFields( { clientId, blockType, attributes, setAttributes } ) {
- - - { blockTitle } - + { isCollapsed && ( + <> + +

+ + { blockTitle } + +

+ + ) } + { ! isCollapsed && ( +

+ { __( 'Content' ) } +

+ ) } ) diff --git a/packages/block-editor/src/hooks/block-fields/styles.scss b/packages/block-editor/src/hooks/block-fields/styles.scss index e4494b67261bc7..1ab62658659481 100644 --- a/packages/block-editor/src/hooks/block-fields/styles.scss +++ b/packages/block-editor/src/hooks/block-fields/styles.scss @@ -30,4 +30,5 @@ .block-editor-block-fields__header-title { flex: 1; + margin: 0 !important; } From 883ec6f1a019644ca92cdb9eaf7e40cf7cab9144 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Fri, 9 Jan 2026 16:30:36 +0800 Subject: [PATCH 3/6] Add comment --- packages/block-editor/src/hooks/block-fields/styles.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/block-editor/src/hooks/block-fields/styles.scss b/packages/block-editor/src/hooks/block-fields/styles.scss index 1ab62658659481..83b08d0e881b8d 100644 --- a/packages/block-editor/src/hooks/block-fields/styles.scss +++ b/packages/block-editor/src/hooks/block-fields/styles.scss @@ -30,5 +30,6 @@ .block-editor-block-fields__header-title { flex: 1; + // Override the default margin on a h2 element. margin: 0 !important; } From ef462a95121a7c429e6b4ee0433cb5ae02ab4ad8 Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 12 Jan 2026 12:58:30 +0800 Subject: [PATCH 4/6] Hide dropdown for non-collapsed mode --- packages/block-editor/src/hooks/block-fields/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-editor/src/hooks/block-fields/index.js b/packages/block-editor/src/hooks/block-fields/index.js index 951e1d9e8012f2..27da4b6b42910e 100644 --- a/packages/block-editor/src/hooks/block-fields/index.js +++ b/packages/block-editor/src/hooks/block-fields/index.js @@ -338,6 +338,11 @@ function BlockFields( { { blockTitle } + ) } { ! isCollapsed && ( @@ -345,11 +350,6 @@ function BlockFields( { { __( 'Content' ) } ) } -
Date: Mon, 12 Jan 2026 13:06:43 +0800 Subject: [PATCH 5/6] Add doc block comment for BlockFields component --- .../block-editor/src/hooks/block-fields/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/block-editor/src/hooks/block-fields/index.js b/packages/block-editor/src/hooks/block-fields/index.js index 27da4b6b42910e..aee23199f30934 100644 --- a/packages/block-editor/src/hooks/block-fields/index.js +++ b/packages/block-editor/src/hooks/block-fields/index.js @@ -170,6 +170,18 @@ function denormalizeLinkValue( value, fieldDef ) { return result; } +/** + * Component that renders a DataForm for a single block's attributes + * @param {Object} props + * @param {string} props.clientId The clientId of the block. + * @param {Object} props.blockType The blockType definition. + * @param {Object} props.attributes The block's attribute values. + * @param {Function} props.setAttributes Action to set the block's attributes. + * @param {boolean} props.isCollapsed Whether the DataForm is rendered as 'collapsed' with only the first field + * displayed by default. When collapsed a dropdown is displayed to allow + * displaying additional fields. The block's title is displayed as the title. + * The collapsed mode is often used when multiple BlockForm's are shown together. + */ function BlockFields( { clientId, blockType, From 0b1129e74e25f0a9c4743a46741383edaf85001e Mon Sep 17 00:00:00 2001 From: Daniel Richards Date: Mon, 12 Jan 2026 13:08:19 +0800 Subject: [PATCH 6/6] Fix typo --- packages/block-editor/src/hooks/block-fields/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/hooks/block-fields/index.js b/packages/block-editor/src/hooks/block-fields/index.js index aee23199f30934..809e16463fe0e2 100644 --- a/packages/block-editor/src/hooks/block-fields/index.js +++ b/packages/block-editor/src/hooks/block-fields/index.js @@ -180,7 +180,7 @@ function denormalizeLinkValue( value, fieldDef ) { * @param {boolean} props.isCollapsed Whether the DataForm is rendered as 'collapsed' with only the first field * displayed by default. When collapsed a dropdown is displayed to allow * displaying additional fields. The block's title is displayed as the title. - * The collapsed mode is often used when multiple BlockForm's are shown together. + * The collapsed mode is often used when multiple BlockForms are shown together. */ function BlockFields( { clientId,