WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.47k stars 4.18k forks source link

HTML Anchors for Pattern Overrides #64414

Open asafm7 opened 2 months ago

asafm7 commented 2 months ago

Description

HTML Anchor attribute setting is available on a global level for an overridden block.

This makes the HTML invalid (as the ID should be unique) and impossible to use HTML Anchors inside patterns.

Step-by-step reproduction instructions

  1. A synced pattern with an overridden heading.
  2. There is no way to create a unique ID for each heading, for in-page navigation.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

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

talldan commented 2 months ago

Thanks for reporting this. I think this is an existing issue for patterns, even before overrides existed. Any heading (or other block that supports 'anchor') in a pattern would be duplicated, including the anchor, when that pattern is inserted twice in the same post. Users would probably solve this by detaching the pattern content and editing it.

Block bindings/pattern overrides supporting the anchor attribute is a good opportunity to solve this.

There would be some UI issues to solve as the anchor attribute is presented in the block inspector, and that's unavailable for overriden blocks in patterns (due to the contentOnly UI - see Advancing contentOnly editing).

cc @SantosGuillamot, this might be something to consider on the block bindings roadmap.