Skip to content

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

Open

Description

@yashjawale

Description

#74183 added anchor support to the Comments Title and Comments Form blocks, but both already output an id on the same element, so the anchor creates a duplicate id and browsers ignore it:

  • Comments Title hardcodes id="comments" (from Create comments title with simple styling #40419): <h2 id="comments" id="my-anchor" class="wp-block-comments-title">
  • Comments Form gets id="respond" from comment_form(): <div id="respond" class="comment-respond wp-block-post-comments-form" id="my-anchor"> ref

Letting the anchor replace these IDs perhaps won't be good: #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 by comment-reply.js to move the form when replying.

Proposed fix: remove anchor support from both blocks. The anchor has never worked on them, and the parent Comments block's anchor can be used instead.

Step-by-step reproduction instructions

  1. Open single posts template
  2. Give anchors to Comments Title block & Comments Form block
  3. To a test post, post a comment so the comment title is visible
  4. Open the post page in chrome & press Cmd + Opt + U or the view source option in devtools to view the outputted HTML (parsed HTML in devtools gets rid of duplicate ID)
  5. Check the id attribute showing up twice.

Screenshots, screen recording, code snippet

image
image

Environment info

Gutenberg trunk via wp-env
Using default Ipsum theme

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] Bug
    on Nov 13, 2026
  2. changed the title [-]Comments Title and Comments Form: HTML anchor is ignored because the block already outputs an `id`[/-] [+]Comments Title & Comments Form: HTML anchor is ignored because the block already outputs an `id`[/+] on Nov 13, 2026
  3. added
    [Status] In Progress
    on Nov 13, 2026
  4. added
    [Block] Comments Form
    [Block] Comments Title
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Block] Comments Form[Block] Comments Title[Status] In Progress[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions