Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* WordPress dependencies
*/
import { useSelect } from '@wordpress/data';
import { useSelect, useDispatch } from '@wordpress/data';
import { useEffect } from '@wordpress/element';
import {
InnerBlocks,
useBlockProps,
Expand Down Expand Up @@ -67,6 +68,19 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
}
);

const { __unstableMarkNextChangeAsNotPersistent } =
useDispatch( blockEditorStore );
const { inherit } = layout;
useEffect( () => {
// If a block has not yet set the `inherit` value to either `true` or `false`,
// and it doesn't have any inner blocks, then set it to the desired default value.
// This ensures that newly inserted blocks are set to use the root/global content sizes.
if ( inherit === undefined && ! hasInnerBlocks ) {
__unstableMarkNextChangeAsNotPersistent();
setAttributes( { layout: { inherit: true } } );
}
}, [ hasInnerBlocks, inherit ] );

return (
<>
<InspectorControls __experimentalGroup="advanced">
Expand Down