Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mechanism to Heading blocks that allows you to control the available levels #63527

Closed
ndiego opened this issue Jul 13, 2024 · 3 comments · Fixed by #63535
Closed

Add a mechanism to Heading blocks that allows you to control the available levels #63527

ndiego opened this issue Jul 13, 2024 · 3 comments · Fixed by #63535
Assignees
Labels
[Block] Heading Affects the Headings Block [Feature] Extensibility The ability to extend blocks or the editing experience [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@ndiego
Copy link
Member

ndiego commented Jul 13, 2024

The heading level dropdown in the Heading block is powered by the HeadingLevelDropdown component. This component accepts and options parameter that allows you to choose which levels are available in the dropdown. Unfortunately, there is no way to modify this options parameter from a Heading block.

Being able to modify the available levels is critical for heavily curated editing environments and block "governance".

Consider the following situations:

  • You only want to allow h2, h3, and h4 in Media & Text blocks.
  • You want to disable h1 on posts since the template already populates an h1 for the post title.
  • You want to disable the usage of h5 and h6 across the whole site.
  • etc.

Curating the available heading levels is currently not possible, but it should be easy to implement using an additional attribute for the Heading block. Developers can then modify this attribute as they need, either directly in theme patterns and templates or via block filters like blocks.registerBlockType or register_block_type_args.

Current functionality Goal
image image

Should the mechanism be added to Heading blocks, we should explore similar mechanisms for other blocks with level dropdowns, like Site Title, Post Title, etc.

@ndiego ndiego added [Type] Enhancement A suggestion for improvement. [Feature] Extensibility The ability to extend blocks or the editing experience [Block] Heading Affects the Headings Block labels Jul 13, 2024
@ndiego
Copy link
Member Author

ndiego commented Jul 13, 2024

cc @troychaplin @ryanwelcher

@troychaplin
Copy link
Contributor

Thanks for adding this issue @ndiego, this would be a fantastic addition to blocks. Allowing users to freely use H1 in the content area create inaccessible content. Best practices state that only 1 unique H1 should be used on the page, preferably placed above the main content, aka the page title. Outside of a11y concerns, more than one H1 on a page can also have a negative impact on SEO.

IMO the heading block should never allow an H1 to be used in the content area, but that's rather heavy handed so at a minimum, an option to remove it would be amazing!

@skorasaurus
Copy link
Member

@ndiego Thanks for the clear writeup although this request seems to be covered pretty well under #20213.

@skorasaurus skorasaurus added the [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed label Jul 13, 2024
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Heading Affects the Headings Block [Feature] Extensibility The ability to extend blocks or the editing experience [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants