From 6e726ea2959cd953be4184335efbbc88da677748 Mon Sep 17 00:00:00 2001
From: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Date: Mon, 27 Mar 2023 15:56:12 +1100
Subject: [PATCH 1/2] Group Block: Ensure blocks can be dragged onto it in its
placeholder state
---
packages/block-library/src/group/edit.js | 34 +++++++++++++++++-------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/packages/block-library/src/group/edit.js b/packages/block-library/src/group/edit.js
index 452da6e7f3238..4ee21704a217f 100644
--- a/packages/block-library/src/group/edit.js
+++ b/packages/block-library/src/group/edit.js
@@ -12,6 +12,7 @@ import {
} from '@wordpress/block-editor';
import { SelectControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
+import { View } from '@wordpress/primitives';
/**
* Internal dependencies
@@ -108,16 +109,28 @@ function GroupEdit( {
usedLayoutType: usedLayout?.type,
hasInnerBlocks,
} );
+
+ // Default to the regular appender being rendered.
+ let renderAppender;
+ if ( showPlaceholder ) {
+ // In the placeholder state, ensure the appender is not rendered.
+ // This is needed because `...innerBlocksProps` is used in the placeholder
+ // state so that blocks can dragged onto the placeholder area
+ // from both the list view and in the editor canvas.
+ renderAppender = false;
+ } else if ( ! hasInnerBlocks && ! showPlaceholder ) {
+ // When there is no placeholder, but the block is also empty,
+ // use the larger button appender.
+ renderAppender = InnerBlocks.ButtonBlockAppender;
+ }
+
const innerBlocksProps = useInnerBlocksProps(
layoutSupportEnabled
? blockProps
: { className: 'wp-block-group__inner-container' },
{
templateLock,
- renderAppender: hasInnerBlocks
- ? undefined
- : InnerBlocks.ButtonBlockAppender,
- __unstableDisableLayoutClassNames: ! layoutSupportEnabled,
+ renderAppender,
}
);
@@ -138,11 +151,14 @@ function GroupEdit( {
}
/>
{ showPlaceholder && (
-
+
+ { innerBlocksProps.children }
+
+
) }
{ layoutSupportEnabled && ! showPlaceholder && (
From 1aac16c051aefc03e80b6bd5ba60ef7b6d86b4f0 Mon Sep 17 00:00:00 2001
From: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
Date: Mon, 27 Mar 2023 16:22:06 +1100
Subject: [PATCH 2/2] Simplify else if condition
---
packages/block-library/src/group/edit.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/block-library/src/group/edit.js b/packages/block-library/src/group/edit.js
index 4ee21704a217f..dac397becc8cb 100644
--- a/packages/block-library/src/group/edit.js
+++ b/packages/block-library/src/group/edit.js
@@ -118,7 +118,7 @@ function GroupEdit( {
// state so that blocks can dragged onto the placeholder area
// from both the list view and in the editor canvas.
renderAppender = false;
- } else if ( ! hasInnerBlocks && ! showPlaceholder ) {
+ } else if ( ! hasInnerBlocks ) {
// When there is no placeholder, but the block is also empty,
// use the larger button appender.
renderAppender = InnerBlocks.ButtonBlockAppender;