diff --git a/packages/block-editor/src/components/block-switcher/index.js b/packages/block-editor/src/components/block-switcher/index.js index 9ee755215a1a7a..003e5a9722f2fa 100644 --- a/packages/block-editor/src/components/block-switcher/index.js +++ b/packages/block-editor/src/components/block-switcher/index.js @@ -91,7 +91,7 @@ export const BlockSwitcherDropdownMenu = ( { clientIds, blocks } ) => { firstBlockName, '__experimentalSection', false - ) && !! getBlockAttributes( clientId ).section, + ) && !! getBlockAttributes( clientId ).metadata?.isSection, }; }, [ clientIds, blocks, blockInformation?.icon ] diff --git a/packages/block-editor/src/components/block-title/test/index.js b/packages/block-editor/src/components/block-title/test/index.js index e83dc0708ae6cf..c696d6c59e95d4 100644 --- a/packages/block-editor/src/components/block-title/test/index.js +++ b/packages/block-editor/src/components/block-title/test/index.js @@ -189,7 +189,9 @@ describe( 'BlockTitle', () => { it( 'should return section title if the block supports it', () => { useSelect.mockImplementation( () => ( { name: 'name-with-section', - attributes: { section: { name: 'My custom section' } }, + attributes: { + metadata: { name: 'My custom section', isSection: true }, + }, } ) ); const wrapper = shallow( diff --git a/packages/block-editor/src/components/block-title/use-block-display-title.js b/packages/block-editor/src/components/block-title/use-block-display-title.js index 315be1e69f682a..c06f8e2de85183 100644 --- a/packages/block-editor/src/components/block-title/use-block-display-title.js +++ b/packages/block-editor/src/components/block-title/use-block-display-title.js @@ -74,7 +74,8 @@ export default function useBlockDisplayTitle( clientId, maximumLength ) { const sectionTitle = hasBlockSupport( name, '__experimentalSection', false ) && - attributes.section?.name; + attributes.metadata?.isSection && + attributes.metadata?.name; const label = sectionTitle || reusableBlockTitle || blockLabel; // Label will fallback to the title if no label is defined for the current diff --git a/packages/block-editor/src/hooks/sections.js b/packages/block-editor/src/hooks/sections.js index 93749388352773..bffb808b303737 100644 --- a/packages/block-editor/src/hooks/sections.js +++ b/packages/block-editor/src/hooks/sections.js @@ -18,11 +18,11 @@ import { hasBlockSupport } from '@wordpress/blocks'; */ export function addAttribute( settings ) { if ( hasBlockSupport( settings, '__experimentalSection', false ) ) { - // Allow blocks to specify their own section attribute definition with default value if needed. - if ( ! has( settings.attributes, [ 'section' ] ) ) { + // Allow blocks to specify their own metadata attribute definition with default value if needed. + if ( ! has( settings.attributes, [ 'metadata' ] ) ) { settings.attributes = { ...settings.attributes, - section: { + metadata: { type: 'object', }, };