Skip to content

Comments Title & Comments Form: Remove anchor support that conflicts with their fixed IDs - #86801

Open
yashjawale wants to merge 5 commits into
WordPress:trunkfrom
yashjawale:fix/comments-blocks-anchor-hardcode
Open

yashjawale wants to merge 5 commits into
WordPress:trunkfrom
yashjawale:fix/comments-blocks-anchor-hardcode

Conversation

@yashjawale

Copy link
Copy Markdown
Contributor

What?

Closes #86800

Removes anchor support from the Comments Title and Comments Form blocks.

Why?

#74183 added anchor support to both, but they already output an id on the same element (id="comments" from #40419, and id="respond" from comment_form()). The anchor creates a duplicate id, and browsers ignore it, so it has never worked.

The anchor can't replace these IDs either: #comments is linked to by get_comments_link(), comments_popup_link() and the Comments Count Link block, and #respond is used by get_comments_link() and comment-reply.js to move the form when replying.

How?

Removes "anchor": true from both block.json files and regenerates the block docs. Existing anchors are ignored on render, so perhaps no deprecation is needed...?

The parent Comments block's anchor can be used instead.

Testing Instructions

  1. Open the Single Posts template.
  2. Select the Comments Title and Comments Form blocks: Advanced no longer shows an HTML anchor field.
  3. Post a comment on a test post so that Comments Title shows.
  4. View the post's source (Cmd + Opt + U): each element has a single id (comments / respond), including in templates that already had an anchor saved.

Screenshots or screencast

Before

image --- |image

After

image image

Use of AI Tools

Assisted by Claude Code, all changes reviewed & tested manually.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Nov 13, 2026
@yashjawale
yashjawale marked this pull request as ready for review November 13, 2026 11:52
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

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: yashjawale <yashjawale@git.wordpress.org>
Co-authored-by: jamesbregenzer <jamesbregenzer@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

Copy link
Copy Markdown

Thanks for the fix. I tested previously saved anchor attributes on both blocks using two disposable WordPress 7.2 Beta 5 sites. With the original metadata, Comments Title rendered IDs comments and legacy-title, while Comments Form rendered respond and legacy-form. With this PR’s two metadata changes applied, the same saved blocks retained just comments and respond.

The test used a synthetic post and approved comment with PHP 8.4.27 via WebAssembly and SQLite. It did not run the full Gutenberg plugin, editor or browser. A regression test using saved anchors could preserve this behavior.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Block API API that allows to express the block paradigm. [Block] Comments Form Affects the Comments Form Block [Block] Comments Title Affects the Comments Title Block labels Nov 15, 2026
@yashjawale

Copy link
Copy Markdown
Contributor Author

Thanks!
Updated to include regression test for preserving the behavior.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Comments Form Affects the Comments Form Block [Block] Comments Title Affects the Comments Title Block [Feature] Block API API that allows to express the block paradigm. [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Comments Title & Comments Form: HTML anchor is ignored because the block already outputs an id

3 participants