Skip to content

Explore how to re-add anchor support to dynamic blocks #51402

@t-hamano

Description

@t-hamano

In #44771, anchor support was added to dynamic blocks, but static blocks with existing anchor were broken (See #48232, #49382, and #49578).

This feature was originally planned to be included in WordPress 6.2, but #48232 was the first to report this issue during the Beta phase. Therefore, by #48592, this feature was excluded in the WordPress 6.2 release.

However, this feature still remains on the Gutenberg plugin, which will be bundled with WordPress 6.3 and will cause similar problems. A solution was attempted in #48438, but we reverted in #51288 anchor support for dynamic blocks in the Gutenberg plugin as well, in order to find a more ideal solution.

One approach I have explored is described in this comment:

  • The allowed values for supports.anchor are false, true, "html", or "delimiter". The block.json schema and document have also been updated.
  • If the value is true or "html", the attribute is taken from the markup of the root element.
  • If the value is delimiter, the attribute is taken from the comment delimiter.
  • Based on these specifications, in dynamic blocks where anchor support was added in #44771, the value of the anchor property was changed to "delimiter".
  • With the increased selection of possible values for anchor, several tests have been added to the unit test for addAttribute().

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] BlocksOverall functionality of blocks[Type] TaskIssues or PRs that have been broken down into an individual action to take

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions