Skip to content

Commit

Permalink
Apply layout to outer wrapper if legacy Group
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Oct 26, 2022
1 parent d34bb68 commit e87b92b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/block-editor/src/components/inner-blocks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const ForwardedInnerBlocks = forwardRef( ( props, ref ) => {
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
*/
export function useInnerBlocksProps( props = {}, options = {} ) {
const { __experimentalLayout } = options;
const { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =
useBlockEditContext();
const isSmallScreen = useViewportMatch( 'medium', '<' );
Expand Down Expand Up @@ -207,10 +208,10 @@ export function useInnerBlocksProps( props = {}, options = {} ) {
ref,
className: classnames(
props.className,
layoutClassNames,
'block-editor-block-list__layout',
{
'has-overlay': hasOverlay,
[ layoutClassNames ]: __experimentalLayout,
}
),
children: clientId ? (
Expand Down
11 changes: 9 additions & 2 deletions packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const htmlElementMessages = {
),
};

function GroupEdit( { attributes, setAttributes, clientId } ) {
function GroupEdit( {
attributes,
setAttributes,
clientId,
__unstableLayoutClassNames: layoutClassNames,
} ) {
const { hasInnerBlocks, themeSupportsLayout } = useSelect(
( select ) => {
const { getBlock, getSettings } = select( blockEditorStore );
Expand All @@ -55,7 +60,9 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
const { type = 'default' } = usedLayout;
const layoutSupportEnabled = themeSupportsLayout || type === 'flex';

const blockProps = useBlockProps();
const blockProps = useBlockProps( {
className: ! layoutSupportEnabled ? layoutClassNames : null,
} );

const innerBlocksProps = useInnerBlocksProps(
layoutSupportEnabled
Expand Down

0 comments on commit e87b92b

Please sign in to comment.