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

Option to set title for the Table of Contents block #52378

Open
huubl opened this issue Jul 6, 2023 · 5 comments
Open

Option to set title for the Table of Contents block #52378

huubl opened this issue Jul 6, 2023 · 5 comments
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.

Comments

@huubl
Copy link
Contributor

huubl commented Jul 6, 2023

What problem does this address?

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

What is your proposed solution?

Option to set a title for the Table of Contents block, something like this:

image

And this as HTML:

<nav class="wp-block-table-of-contents">
    <!-- POSSIBILITY TO ADD THIS: -->
    <h2 class="wp-block-table-of-contents__title">Contents on this page:</h2>
    <ol>
        <li>
            <a class="wp-block-table-of-contents__entry" href="https://test.local/#heading-page-1">heading page 1</a>
        </li>
        <li>
            <a class="wp-block-table-of-contents__entry" href="https://test.local/#heading-page-2">heading page 2</a>
        </li>
        <li>
            <a class="wp-block-table-of-contents__entry" href="https://test.local/#heading-page-3">heading page 3</a>
        </li>
    </ol>
</nav>
@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Table of contents (experimental) Affects the Table of contents Block labels Jul 6, 2023
@afercia afercia added the [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). label Jul 14, 2023
@afercia
Copy link
Contributor

afercia commented Jul 14, 2023

Thanks for reporting this issue.
It appears the TOC block needs some more improvements.

  • By default it outputs a <nav> element. There's no way to label this element. When a page contains more than one <nav> element, they must be labelled to be distinguishable.
  • Labelling can be done by teh means of an aria-label attribute, when there is no heading.
  • Instead, when there is a heading, labelling should be implemented by the means of aria-labelledby pointing to the visible heading.

As an aside: an old version of the ARIA Authoring Practices used a directory role for the Table of contents. This role has been then deprecated in ARIA 1.2. In the same document, the 'Example 14' used a navigation rike fir. the Table of contents, which didn't help with clarity. ARIA 1.2 and the related Authoring practices don't provide any recommendation for Table of contents, as far as I can tell. A <nav> element seems reasonable, as long as it is labelled.

@Mamaduka
Copy link
Member

Related #51129.

@alexstine
Copy link
Contributor

Honestly, table of contents with navigation landmark can sometimes be more noise then it is truly worth. I am very much on the fense about landmarks inside landmarks because once you enter a nav inside main, there is no way to get back to main as the next logical landmark is the footer on most sites or sometimes aside.

@00travelgirl00
Copy link

@alexstine thats an intresting info. Just out of curiosity: Would you prefer a nav to stand alone or to be inside a aside? Question is not related to tables, but for post-navigtions for example.

@alexstine
Copy link
Contributor

Post navigation really needs a navigation landmark but it is generally near the end of the main content so it is less of a problem. This is a clear example of how screen readers should do better but I'm not really sure how the future looks there.

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.
6 participants