-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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.
Reproduction
Use ::: details inside a markdown list:
* ::: details <span>Collapsible group</span>
* `field1` - Description of field 1
* `field2` - Description of field 2This 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
documentshows the event target isDETAILS.details.custom-block, notSUMMARY - 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).