Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Buttons styling issue caused by Layout support being applied to blocks that have not opted in #34189

Closed
Closed
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ function gutenberg_get_layout_style( $selector, $layout ) {
* @return string Filtered block content.
*/
function gutenberg_render_layout_support_flag( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$support_layout = gutenberg_block_has_support( $block_type, array( '__experimentalLayout' ), false );
$has_innner_blocks = count( $block['innerBlocks'] ) > 0;
if ( ! $support_layout && ! $has_innner_blocks ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$support_layout = gutenberg_block_has_support( $block_type, array( '__experimentalLayout' ), false );

if ( ! $support_layout ) {
return $block_content;
}

Expand Down
11 changes: 2 additions & 9 deletions packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,12 @@ export const withInspectorControls = createHigherOrderComponent(
*/
export const withLayoutStyles = createHigherOrderComponent(
( BlockListBlock ) => ( props ) => {
const { name, attributes, clientId } = props;
const { name, attributes } = props;
const supportLayout = hasBlockSupport( name, layoutBlockSupportKey );
const id = useInstanceId( BlockListBlock );
const defaultLayout = useSetting( 'layout' ) || {};
const hasInnerBlocks = useSelect(
( select ) => {
const { getBlockCount } = select( blockEditorStore );
return getBlockCount( clientId ) > 0;
},
[ clientId ]
);
const element = useContext( BlockList.__unstableElementContext );
const shouldRenderLayoutStyles = supportLayout || hasInnerBlocks;
const shouldRenderLayoutStyles = supportLayout;
const { layout = {} } = attributes;
const usedLayout = !! layout && layout.inherit ? defaultLayout : layout;
const className = classnames( props?.className, {
Expand Down