Skip to content

Adding heading to TOC#68805

Closed
benazeer-ben wants to merge 2 commits intoWordPress:trunkfrom
benazeer-ben:toc-heading
Closed

Adding heading to TOC#68805
benazeer-ben wants to merge 2 commits intoWordPress:trunkfrom
benazeer-ben:toc-heading

Conversation

@benazeer-ben
Copy link
Contributor

@benazeer-ben benazeer-ben commented Jan 21, 2025

What?

Fixes : #52378

Why?

There is no good way of setting a title for the Table of Contents block

How?

Added settings to include title for the Table of Content block.

Testing Instructions

  • Open a post or page.
  • Insert a heading block.
  • Check the settings added to include title for the block.
  • Verify the title is displaying properly in editor and frontend.

Screenshots or screencast

Before After
Screenshot (4) Screenshot (5)

@github-actions
Copy link

github-actions bot commented Jan 21, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: benazeer-ben <benazeer@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Marc-pi <mdxfr@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: alexstine <alexstine@git.wordpress.org>
Co-authored-by: 00travelgirl00 <travel_girl@git.wordpress.org>
Co-authored-by: huubl <huubl@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Table of contents (experimental) Affects the Table of contents Block labels Jan 22, 2025
@benazeer-ben
Copy link
Contributor Author

benazeer-ben commented Feb 12, 2025

Could someone review this PR when available? @Mamaduka @ajitbohra @fabiankaegy

Let me know if you'd like any further refinements!

Thanks in advance!

@benazeer-ben
Copy link
Contributor Author

Hi Team,

Whenever you have some time, could you please review this PR? I’d really appreciate your feedback.

Thanks in advance!

cc: @t-hamano @carolinan

@carolinan
Copy link
Contributor

Hi, the table of content block is still experimental, personally I am not able to prioritise it.

@t-hamano
Copy link
Contributor

t-hamano commented Mar 7, 2025

Thanks for the PR!

From reading the issue, it seems like the current TOC block needs some improvement from an accessibility perspective, so simply adding an h2 heading option might not be the best solution.

Before proceeding with implementation, it is a good idea to consider what specification would be the ideal approach.

@Marc-pi
Copy link

Marc-pi commented Aug 8, 2025

well, that's a strong need, instead of having to encapsulate it into a group block just to add a free paragraph in it on top of ToC.

  • this text should not have by default any heading level
  • personally i never add such a Hn on top ToC list, only a simple paragraph (ex: "Summary")

@t-hamano
Copy link
Contributor

t-hamano commented Aug 9, 2025

Let's close this PR and consider a more ideal approach. Looking at #52378, I think we need to discuss the more fundamental issues below first:

  • The block outputs a nav element, but there is no way to label it.
  • On the other hand, tables of contents with navigation landmark can sometimes be noisy.

@benazeer-ben Thank you for your efforts!

@t-hamano t-hamano closed this Aug 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Table of contents (experimental) Affects the Table of contents Block [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to set title for the Table of Contents block

5 participants