From 45c03ac3cc9fba28ece589378dabf8bfcdaef2d2 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 21 Feb 2024 08:59:05 +0400 Subject: [PATCH] Set the 'defaultBlock' setting for Columns & List blocks (#59196) Co-authored-by: Mamaduka Co-authored-by: ramonjd --- packages/block-library/src/columns/edit.js | 6 ++++++ packages/block-library/src/list/edit.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index 95e0ba43efb438..0a756b34c6ef6f 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -40,6 +40,10 @@ import { toWidthPrecision, } from './utils'; +const DEFAULT_BLOCK = { + name: 'core/column', +}; + function ColumnsEditContainer( { attributes, setAttributes, clientId } ) { const { isStackedOnMobile, verticalAlignment, templateLock } = attributes; const { count, canInsertColumnBlock, minCount } = useSelect( @@ -90,6 +94,8 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) { className: classes, } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { + defaultBlock: DEFAULT_BLOCK, + directInsert: true, orientation: 'horizontal', renderAppender: false, templateLock, diff --git a/packages/block-library/src/list/edit.js b/packages/block-library/src/list/edit.js index ad294de93e77b1..94a7a0945d6294 100644 --- a/packages/block-library/src/list/edit.js +++ b/packages/block-library/src/list/edit.js @@ -29,6 +29,9 @@ import OrderedListSettings from './ordered-list-settings'; import { migrateToListV2 } from './utils'; import TagName from './tag-name'; +const DEFAULT_BLOCK = { + name: 'core/list-item', +}; const TEMPLATE = [ [ 'core/list-item' ] ]; const NATIVE_MARGIN_SPACING = 8; @@ -125,6 +128,8 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) { } ); const innerBlocksProps = useInnerBlocksProps( blockProps, { + defaultBlock: DEFAULT_BLOCK, + directInsert: true, template: TEMPLATE, templateLock: false, templateInsertUpdatesSelection: true,