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

Dropdown in dropdown events not passing through due to ::before close pseudoelement #614

Open
mwargan opened this issue Sep 27, 2024 · 4 comments

Comments

@mwargan
Copy link

mwargan commented Sep 27, 2024

Please search for duplicate or closed issues first.

Describe the issue

When placing a dropdown in a dropdown, the click events of elements inside the parent dropdown get masked and non-clickable due to the ::before element that is used as the "click on background to close" handler.

Current Behavior

All elements within a dropdown containing another dropdown non-clickable except for the last child-dropdown.

Expected Behavior

The click events to work as expected

Reproduction URL

https://jsfiddle.net/f9v860hk/3/

<details class="dropdown">
   <summary> Select a phase of matter... </summary>
   <ul>
      <li><label><input type="radio" name="phase" value="solid"> Solid </label></li>
      <li><label><input type="radio" name="phase" value="liquid"> Liquid </label></li>
      <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>
      <li>
         <details>
            <summary> This is a dropdown option 2 </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>

Environment

Safari MacOS, probably others.

Suggested fix

/*
* Fix Option 1 - do not render ::before when details not open
*
*
*/
details:not([open]) > summary::before {
  content: none !important;
}

/*
* Fix Option 2 - do not render ::before on children
*
*
*/
details details:not([open]) > summary::before {
  content: none !important;
}

obviously more specific selectors would have to be used / written a bit better so as to avoid the use of !important, but I just didn't look into it much more yet.

@mwargan
Copy link
Author

mwargan commented Sep 27, 2024

Note my suggested fix fails in the case of having another dropdown as a direct child of details (rather than in a ul as I've shown in the original issue):

<details class="dropdown">
  <summary>Select a phase of matter...</summary>
  <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>
  <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>
</details>

@mwargan
Copy link
Author

mwargan commented Sep 28, 2024

There is another problem in rendering that causes any details elements as children of a dropdown to also render as a dropdown. This is due to this line details.dropdown[open] summary::before which selects all summary children.

1 similar comment
@mwargan
Copy link
Author

mwargan commented Sep 28, 2024

There is another problem in rendering that causes any details elements as children of a dropdown to also render as a dropdown. This is due to this line details.dropdown[open] summary::before which selects all summary children.

@mwargan
Copy link
Author

mwargan commented Sep 28, 2024

There is another problem in rendering that causes any details elements as children of a dropdown to also render as a dropdown. This is due to this line details.dropdown[open] summary::before which selects all summary children.

I have issued a fix for this specific issue here #615

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

No branches or pull requests

1 participant