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

Legacy Group inner block wrapper should work with constrained layout. #44660

Merged
merged 4 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function gutenberg_restore_group_inner_container( $block_content, $block ) {
if (
WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ||
1 === preg_match( $group_with_inner_container_regex, $block_content ) ||
( isset( $block['attrs']['layout']['type'] ) && 'default' !== $block['attrs']['layout']['type'] )
( isset( $block['attrs']['layout']['type'] ) && 'flex' === $block['attrs']['layout']['type'] )
) {
return $block_content;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
// When the appender shows up in empty container blocks, such as Group and Columns, add an extra click state.
.block-list-appender:only-child {
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > &,
.is-layout-flow.block-editor-block-list__block:not(.is-selected) > & {
.is-layout-flow.block-editor-block-list__block:not(.is-selected) > &,
.is-layout-constrained.block-editor-block-list__block:not(.is-selected) .block-editor-block-list__layout > &,
.is-layout-flow.block-editor-block-list__block:not(.is-selected) .block-editor-block-list__layout > & {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add these styles so that empty Group blocks in classic themes, where the block has an inner wrapper, also show the non-selected state. Cc @jasmussen in case you have better ideas on how to address this!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to test at the moment, but the main change to consider would be adding a > between the selectors so it only targets the direct descendant, and not any nested groups. Not sure if necessary in practice since the group would by definition be empty and not have anything inside to inherit. 🤔

Though to finish the thought, this would be the alternative:

	.is-layout-constrained.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__layout > &,
	.is-layout-flow.block-editor-block-list__block:not(.is-selected) > .block-editor-block-list__layout > & {

And the way to test would be to add an empty group inside a group. As noted, probably no difference to spot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, as it is it could potentially make a placeholder appear in any child block with only an inserter. I'll update it, thanks!

pointer-events: none;

&::after {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/group/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function GroupEdit( { attributes, setAttributes, clientId } ) {
? { ...defaultLayout, ...layout, type: 'default' }
: { ...defaultLayout, ...layout };
const { type = 'default' } = usedLayout;
const layoutSupportEnabled = themeSupportsLayout || type !== 'default';
const layoutSupportEnabled = themeSupportsLayout || type === 'flex';

const blockProps = useBlockProps();

Expand Down