beercss / beercss

Build material design interfaces in record time... without stress for devs... πŸΊπŸ’›
https://www.beercss.com
MIT License
940 stars 47 forks source link

Menu Component: active class does not work (first method) #282

Open steevepay opened 1 month ago

steevepay commented 1 month ago

The first method to show the menu requires only the class active, however, I couldn't make it work:

<button>
  <span>Button</span>
  <menu class="no-wrap active">
    <a>Item</a>
    <a>Item</a>
    <a>Item</a>
  </menu>
</button>

When I click on an item and remove the class active, the menu is still visible because :not([data-ui]):focus-within > menu CSS definition is taking over. Screenshot:

Screenshot 2024-04-07 at 18 35 31

The alternative solution I found is to add a dummy data-ui, and it will only use the active class to show/hide the menu:

<button data-ui="btn">
  <span>Button</span>
  <menu class="no-wrap active">
    <a>Item</a>
    <a>Item</a>
    <a>Item</a>
  </menu>
</button>