Behavior of the table of content in case of empty header

Hello all,

Currently, a table of content on a page with empty headers, will produce entries with valid anchors and indentation, but with a text equal to the title of the current page.
For instance, assuming a page with title test and a content matching the snippet below:

{{toc/}}

=   =

= level 1 =

==   ==

== level 2  ==

The result is currently:

I’d like to know what result you’d expect. I’ve considered three options.

Option 1 - No toc entries for empty headers

In the case of the example above, the toc would be:

Cons: this could be misleading in case of empty heading in between non-empty headings. For instance:

= H1 =
= =
== H2 ==

H2 would be visually part of the H1 section even though it’s technically not part of it.

Option 2 - Toc entries with an empty text for empty headers

In this case the result for the snippet would be:

The entries are visible and match the actual structure of the document, but the links to empty headers are cannot be clicked.

Option 3 - Toc entries with a space for empty headers

In this case the result for the snippet would be:

In this case the entries are not fully matching the actual content of the empty headers, but they can be clicked.

Here is my +1 for option 3.

Related Jira issue: Loading...

2 Likes

+1 for 3

+1 for 3,

Thanks,
Marius

+1 for 3

thanks for picking this up, seeing the title of your page in the toc can be confusing.

+1 for 3

+1 for 3, thank you!

Thanks for your votes! The corresponding PR is now updated accordingly.

1 Like

I see that the pr is already out but I want to vote for solution 3 too. Here is my explanation: I think it’s a matter of a11y.

I see many users taking empty headers just for styling, to generate bigger empty spaces between paragraphs etc. But that‘s not good for screen readers as they „read“ empty headers anyway.

So solution 3 forces editors to behave in a more accessible way. But on the other hand it can be hard for the editors to find the reason for those empty places in the toc, to find empty headers in their article while using WYSIWYG editor.

But if I had to decide between both sides I prefer more accessibility.

1 Like