Skip to content

Commit

Permalink
Reinstating default "constrained" layout type, but adding an extra ep…
Browse files Browse the repository at this point in the history
…hemeral property to identify blocks that have been inserted.
  • Loading branch information
ramonjd committed Sep 6, 2022
1 parent a09cb81 commit c1b2044
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/block-library/src/group/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
"enum": [ "all", "insert", "noContent", false ]
},
"layout": {
"type": "object"
"type": "object",
"default": {
"type": "constrained",
"isDefault": true
}
}
},
"supports": {
Expand Down
7 changes: 5 additions & 2 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ function GroupEdit( { attributes, name, setAttributes, clientId } ) {
);

const { tagName: TagName = 'div', templateLock, layout = {} } = attributes;
const { type: layoutType = null } = layout;
const { type: layoutType = null, isDefault = false } = layout;

// Whether to show the variations placeholder.
const showPlaceholder = ! layoutType && ! hasInnerBlocks;
// `isDefault: true` only exists in the default layout attributes in block.json
// in order to identify blocks that have been inserted, programmatically or otherwise, with no changes.
// When a user selects a layout `isDefault` won't appear in the block's attributes.
const showPlaceholder = isDefault && ! hasInnerBlocks;

// Layout settings.
const defaultLayout = useSetting( 'layout' ) || {};
Expand Down

0 comments on commit c1b2044

Please sign in to comment.