Make WordPress Core

#56798 closed defect (bug) (duplicate)

Twenty Twenty-Two: Post comments block accessibility fixes

Reported by: desrosj's profile desrosj Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords:
Focuses: accessibility Cc:



The Post Comments block uses an h3 heading on it, this causes a11y issues [as discussed in #43203 (and previously )] on the templates where it's inserted, since there are no existing h2 in them. The new Comments block doesn't have the same problem because it allows you to change the heading as you need, but it's only available with Gutenberg or WP >= 6.1. To solve this issue, we are doing the following:

  • We are creating a hidden block pattern that inserts either of the blocks depending on if the new block is registered and the WP version is >= 6.1
  • For users that will get the deprecated version of the block, we are using the render_block hook to swap the h3 with an h2, and solve the a11y for them
  • Users that will get the newer version of the block, will have the h2 instead.

To test this:

  • Run this branch, check a page with comments on it, you should be seeing the headings using h2. On the editor, you should be seeing the new Comments block (there is no deprecation message present). You may need to tweak this line in hidden-comments.php, since this branch is still not a 6.1 version of WP:

if ( WP_Block_Type_Registry::get_instance()->is_registered( 'core/comments' ) && version_compare( $GLOBALS['wp_version'], '6.1', '>=' ) ) {

  • Run the code from this branch on a 6.0 environment, you should be seeing the old block, with the deprecation notice in the editor. In the frontend, you should still see the headings on the comments block using h2, instead of h3.

Aside from a11y, note that this PR also improves User Experience of the TT2 theme: Users with WP >= 6.1 will get the Comments block in editable mode automatically, rather than seeing the legacy mode and the upgrade notice.

This was raised in #55172, but deemed not a blocker to adding the Accessibility Ready tag. Props to @poena when merged for raising this issue.

Change History (4)

#1 @poena
17 months ago

I believe we only need to keep one of these tickets open?

This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.

17 months ago

This ticket was mentioned in Slack in #accessibility by ryokuhi. View the logs.

17 months ago

#4 @ryokuhi
17 months ago

  • Milestone 6.1.1 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This ticket was discussed today during the accessibility team's weekly bug scrub.
As suggested by @poena, we decided to close this ticket in favor of #56496.
The comment reported by @desrosj in this ticket description from the wordpress-develop Pull Request was also moved to ticket #56496, to keep all the discussion in a single place.

Note: See TracTickets for help on using tickets.