Skip to content

Conversation

@Mamaduka
Copy link
Member

Description

When the plugin is used with WordPress 5.8-betas, the Layout configuration is rendered twice to the block wrapper. PR adds checks for core functions and only users plugin hooks for WP < 5.8.

Fixes #33005.

How has this been tested?

  1. Activate TT1 Blocks
  2. Add a new Group block.
  3. In the Block settings panel, set Layout > Inherit default layout. (I think this step is optional).
  4. Double wp-container-* class and <style> tag shouldn't be appended to Group block container.

Types of changes

Bugfix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@Mamaduka Mamaduka self-assigned this Jun 28, 2021
@Mamaduka Mamaduka added [Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Bug An existing feature does not function as intended labels Jun 28, 2021
@Mamaduka Mamaduka requested a review from youknowriad June 28, 2021 16:05
if ( ! function_exists( 'wp_render_layout_support_flag' ) ) {
// Register the block support.
WP_Block_Supports::get_instance()->register(
'layout',
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally this "key" should be unique and override the existing block support, maybe something to improve in the registry in Core later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Unique key makes sense.

The main problem here is the filters, so I used a single conditional wrapper for both.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should use conditionals or actually override the logic in core in case it changes in the plugin. I think we can probably start with ignoring these changes first though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Block support from the plugin should override one from the core. We can probably use higher priority for filters when we need to override the logic in the core.

https://github.com/WordPress/wordpress-develop/blob/81e1c2d58b8134ddf633a64e4dd0bcb5f94856e2/src/wp-includes/class-wp-block-supports.php#L79

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

LGTM

@Mamaduka
Copy link
Member Author

It looks like double containers also were added to the snapshot.

@youknowriad
Copy link
Contributor

yeah that should have raised flags already :)

@Mamaduka Mamaduka merged commit 9a6fdb0 into trunk Jun 29, 2021
@Mamaduka Mamaduka deleted the fix/duplicated-layout-config branch June 29, 2021 09:11
@github-actions github-actions bot added this to the Gutenberg 11.0 milestone Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Group Affects the Group Block (and row, stack and grid variants) [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Group block: multiple wp-container-* classes and duplicate styles per block

3 participants