Skip to content

Conversation

@R1shabh-Gupta
Copy link
Contributor

@R1shabh-Gupta R1shabh-Gupta commented Sep 4, 2025

What?

Closes #71496

Prevents users from adding comments to empty blocks (unmodified default blocks) and the block inserter placeholder, addressing unexpected behavior in the collaborative commenting feature.

Why?

Currently, the block commenting feature allows users to add comments to empty paragraph blocks and the block inserter placeholder, which feels unexpected and unintuitive. When a user clicks into an empty block or the inserter area, they shouldn't be able to add comments since there's no actual content to comment on.

This issue was identified as part of the Block Commenting iteration for WordPress 6.9 and affects the user experience of the collaborative workflows feature.

How?

The fix adds a check in the AddComment component to detect unmodified default blocks using the existing isUnmodifiedDefaultBlock utility function from @wordpress/blocks. When an empty default block is selected, the comment form is not rendered, preventing users from adding comments to these blocks.

Key changes:

  • Import isUnmodifiedDefaultBlock from @wordpress/blocks
  • Add isEmptyDefaultBlock check in the useSelect hook
  • Prevent rendering the comment form when isEmptyDefaultBlock is true

Testing Instructions

  1. Enable the comments experiment in Gutenberg
  2. Create a new post or page
  3. Add a paragraph block with some content
  4. Add a comment to the paragraph block (this should work normally)
  5. Click on an empty paragraph block or the block inserter placeholder
  6. Verify that no comment form appears in the collaboration sidebar
  7. Try clicking on other content blocks to ensure commenting still works normally

Screenshots or screencast

Before

Before.mov

After

After.mov

@t-hamano t-hamano added the Collaborative Workflows Phase 3 of the Gutenberg roadmap around all-things related to collaborative workflows label Sep 4, 2025
@R1shabh-Gupta R1shabh-Gupta marked this pull request as ready for review September 4, 2025 11:39
@github-actions
Copy link

github-actions bot commented Sep 4, 2025

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.

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

Co-authored-by: R1shabh-Gupta <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: adamsilverstein <[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 the [Type] Bug An existing feature does not function as intended label Sep 11, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs Review in WordPress 6.9 Editor Tasks Sep 11, 2025
@t-hamano t-hamano moved this from 🔎 Needs Review to 🏗️ In Progress in WordPress 6.9 Editor Tasks Sep 11, 2025
@t-hamano t-hamano moved this from 🏗️ In Progress to 🔎 Needs Review in WordPress 6.9 Editor Tasks Sep 11, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM! This works well for me.

@t-hamano t-hamano added the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Sep 11, 2025
@github-actions github-actions bot removed the props-bot Manually triggers Props Bot to ensure the list of props is up to date. label Sep 11, 2025
@t-hamano t-hamano merged commit b51b0ce into WordPress:trunk Sep 11, 2025
87 of 90 checks passed
@github-project-automation github-project-automation bot moved this from 🔎 Needs Review to ✅ Done in WordPress 6.9 Editor Tasks Sep 11, 2025
@github-actions github-actions bot added this to the Gutenberg 21.7 milestone Sep 11, 2025
adamsilverstein added a commit to adamsilverstein/gutenberg that referenced this pull request Sep 11, 2025
Co-authored-by: R1shabh-Gupta <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: adamsilverstein <[email protected]>
@t-hamano t-hamano added [Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting and removed Collaborative Workflows Phase 3 of the Gutenberg roadmap around all-things related to collaborative workflows labels Oct 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Notes Phase 3 of the Gutenberg roadmap around block commenting [Type] Bug An existing feature does not function as intended

Projects

Development

Successfully merging this pull request may close these issues.

Block commenting unexpectedly works on empty blocks / block inserter placeholder

2 participants