Skip to content

details custom-block inside list item doesn't toggle on click #5163

@jtsternberg

Description

@jtsternberg

Describe the bug

<details> elements rendered from the ::: details custom block container don't toggle when clicking the summary row. The native <details> disclosure triangle (chevron) appears via the ::marker pseudo-element on <summary>, but clicks in the summary area land on the <details> element itself rather than <summary>, so the native toggle never fires.

https://a.supportally.com/i/Uc2g1l

Reproduction

Use ::: details inside a markdown list:

* ::: details <span>Collapsible group</span>
    * `field1` - Description of field 1
    * `field2` - Description of field 2

This renders as:

<ul>
  <li>
    <details class="details custom-block">
      <summary>Collapsible group</summary>
      <ul>
        <li><code>field1</code> - Description of field 1</li>
        <li><code>field2</code> - Description of field 2</li>
      </ul>
    </details>
  </li>
</ul>

Clicking the chevron or the summary text does not expand the details.

Root cause

The .custom-block CSS on <details> adds padding that creates a hit area around the <summary>. When clicking what visually appears to be the summary row, the event target is DETAILS (the wrapper), not SUMMARY. Since native <details> toggle behavior only fires when <summary> receives the click, nothing happens.

Evidence from debugging:

  • summary.click() via JavaScript does toggle the details (confirms the HTML structure is valid)
  • Adding a capturing click listener on document shows the event target is DETAILS.details.custom-block, not SUMMARY
  • The summary's own click listener never fires on physical clicks
  • elementFromPoint() at the chevron coordinates returns child elements (<code>) or the details wrapper, not the summary

Expected behavior

Clicking anywhere in the summary row (including the disclosure triangle / ::marker) should toggle the <details> open/closed.

System Info

  • VitePress: 1.6.3
  • Browser: Chrome (macOS)

Possible fix

The .custom-block padding on <details> likely needs to be moved to (or only applied to) the children inside the details, so that the summary row's click target isn't obscured by the details wrapper's padding. Alternatively, a small JS handler could call details.toggleAttribute('open') when the details element itself receives a click (and the click target is not inside the content area).

Metadata

Metadata

Assignees

No one assigned

    Labels

    need more infoFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions