Skip to content

Fix details inside drop-down being rendered as dropdown#615

Merged
lucaslarroche merged 1 commit intopicocss:devfrom
mwargan:patch-1
Mar 9, 2025
Merged

Fix details inside drop-down being rendered as dropdown#615
lucaslarroche merged 1 commit intopicocss:devfrom
mwargan:patch-1

Conversation

@mwargan
Copy link
Contributor

@mwargan mwargan commented Sep 28, 2024

Given a dropdown that contains an accordion within it, the accordion renders as a dropdown because the summary selector also selects the children of a dropdown element. This fixes that so it renders as expected.

<details class="dropdown">
   <summary> Select a phase of matter... </summary>
   <ul>
      <li>
         <details>
            <summary> This is a dropdown option </summary>
            <ul>
               <li><label><input type="radio" name="phase" value="gas"> Gas </label></li>
               <li><label><input type="radio" name="phase" value="plasma"> Plasma </label></li>
            </ul>
         </details>
      </li>
   </ul>
</details>

Note this fix also more closely conforms with the HTML spec https://html.spec.whatwg.org/multipage/interactive-elements.html#the-summary-element as the summary element should be used in the context "As the first child of a details element."

Given a dropdown that contains an accordion within it, the accordion renders as a dropdown because the summary selector also selects the children of a dropdown element. This fixes that so it renders as expected.

```
<details class="dropdown">
   <summary> Select a phase of matter... </summary>
   <ul>
      <li>
         <details>
            <summary> This is a dropdown option </summary>
            <ul>
               <li><label><input type="radio" name="phase" value="gas"> Gas </label></li>
               <li><label><input type="radio" name="phase" value="plasma"> Plasma </label></li>
            </ul>
         </details>
      </li>
   </ul>
</details>
```
@lucaslarroche
Copy link
Member

Thanks @mwargan for spotting this and providing a fix! Nice addition!
Sorry for the delay.
I'll merge this into dev, recompile the CSS files, and it will be included in the next release.

@lucaslarroche lucaslarroche changed the base branch from main to dev March 9, 2025 07:57
@lucaslarroche lucaslarroche merged commit 96ad16e into picocss:dev Mar 9, 2025
@lucaslarroche lucaslarroche mentioned this pull request Mar 9, 2025
@mwargan mwargan deleted the patch-1 branch March 9, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants