Skip to content

Block Supports: Don't merge unique attributes (ID, aria-label) in get_block_wrapper_attributes #75251

@hadamlenz

Description

@hadamlenz

Description

This feature is not backward compatible and creates a space in the anchor, which is not valid html.
if an anchor is set in the block editor, say "my-anchor".
if supports.anchor is set and an attribute "anchor" of type string is set in attributes in block.json
the resulting $block_wrapper_attributtes has an id of "my-anchor my-anchor"
Going back to 22.2.0 fixes the issue, but this means we cannot run the plugin for our own dynamic blocks. If there is a better way, please advise

Step-by-step reproduction instructions

  1. in block.json set supports.anchor=true
  2. in block.json set a string type attribute to hold the anchor
  3. in render.php set the id of get_block_wrapper_attributes()

Screenshots, screen recording, code snippet

Image
$block_wrapper_attributtes = get_block_wrapper_attributes(['id'=>$attributes['anchor']]);

results in

class="..." id="my-anchor my-anchor"

Environment info

WordPress 6.9.1, Gutenberg 22.5.0, 2025 theme
Most current Chrome
16-inch, 2021 M1 MBP running Tahoe 26.2

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Block APIAPI that allows to express the block paradigm.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions