Skip to content

Table of Contents menu shows links to headings within a collapsed <details> #7265

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

The generated tables of contents (ToC) for a markdown page includes headings inside collapsed <details>. Clicking the ToC link does nothing.

This was mentioned back in #5790. I haven't found anything in the [HTML5 spec](https://html.spec.whatwg.org/#the-details-element section on <details>) about disallowing heading content inside it. Some online sites such as https://a11ysupport.io/tech/html/summary_element reference them being allowed. https://stackoverflow.com/questions/49594772/should-i-specify-h2-h6-sub-headings-for-a-details-tag-to-make-the-details-a-dist#:~:text=Headings%20within%20details,)%2C%20provide%20heading%20elements%20within even references it being preferred (though I again can't find a source).

See the typescript-eslint site and PR referenced in this issue for an example of where I'd want this. Specifically, I wanted to include headings inside a details view because there's a lot of content that could benefit from having sections. The details content isn't something most page readers need, though, so I didn't want to have the reading journey on the page include it so early.

member-ordering._.TypeScript.ESLint.-.Google.Chrome.2022-04-29.09-11-02.mp4

Reproducible demo

https://j2rm6f.sse.codesandbox.io/markdown-page

Steps to reproduce

  1. Add a <details> element to a markdown page
  2. Include a ## ... heading inside that details element
  3. View the markdown page

Expected behavior

I would think one of the two would happen:

  • Clicking the ToC heading would expand the <details> element
  • The ToC doesn't show headings inside collapsed <details>

#5790 is related

Actual behavior

The ToC includes headings inside collapsed <details>. Clicking the ToC link does nothing.

Your environment

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executionclosed: duplicateThis issue or pull request already exists in another issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy