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

Comment Template: Add blockGap support #69292

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

yogeshbhutkar
Copy link
Contributor

@yogeshbhutkar yogeshbhutkar commented Feb 24, 2025

What?

Closes #69284
Part of #43243

This PR adds Block Gap support to the Comment Template Block.

Why?

  1. To bring consistency between Post Template and Comment Template.
  2. Currently, users need to provide a bottom margin to add spacing between multiple comments, Block Gap would streamline and simplify the process.

How?

  1. The corresponding block.json was updated to incorporate the support for layout and blockGap.
  2. The tests were effectively handled as per the code comments mentioned below.

Testing Instructions

  1. Create a new Comments Block.
  2. Confirm that the Comment Template was automatically inserted as an inner block.
  3. Navigate to the styles tab of the Comment Template block.
  4. Confirm that the Block Spacing settings are effectively applied on both the editor and front-end screens.

Screencast

block-gap-demo

@yogeshbhutkar yogeshbhutkar changed the title Feat: Add blockGap support to Comment Template WIP: Add blockGap support to Comment Template Feb 24, 2025
@yogeshbhutkar yogeshbhutkar changed the title WIP: Add blockGap support to Comment Template Comment Template: Add blockGap support Feb 25, 2025
@yogeshbhutkar yogeshbhutkar force-pushed the enhance-69284/add-block-gap branch from 36f8fbb to 6d4637c Compare February 25, 2025 07:13

// Set the block name to one that does not correspond to an existing registered block.
// This ensures that for the inner instances of the Comment Template block, we do not render any block supports.
$block_instance['blockName'] = 'core/null';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Setting the blockName of a specific block_instance to core/null effectively prevents unintended layout class names from being applied to inner elements. This approach addresses a known issue and is currently the best way to handle it (as far as I can think).

Reference: PR 41827

@@ -159,7 +159,6 @@ public function test_inner_block_inserted_by_render_block_data_is_retained() {

$args = $render_block_callback->get_args();
$this->assertSame( 'core/comment-content', $args[0][2]->name );
$this->assertSame( 'core/comment-template', $args[1][2]->name );
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is necessary after making the changes mentioned above.

Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @EldarAgalarov.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: EldarAgalarov.

Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: coder-rancho <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Comment Template Affects the Comment Template Block labels Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comment Template Affects the Comment Template Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comment Template: Missing blockGap option
2 participants