mrwweb / clicky-menus

Simple click-triggered navigation submenus. Accessible and progressively enhanced.
MIT License
90 stars 15 forks source link

Add support for a data-attribute to close open submenus #21

Open mrwweb opened 1 month ago

mrwweb commented 1 month ago

Now that it's possible to close an open submenu from anywhere in the DOM (#18), it would be a very nice developer convenience to declaratively use that feature.

So my current thought is this:

<button data-close-clicky-menus="menu-id">Close Open Menu</button>

Where "menu-id" is the ID of a valid clicky-menu instance. If that were in the DOM when the script first executes, I could find those instances and then automatically handle closing submenus when the button is clicked, reducing requirements for custom code.

ajplopez commented 1 month ago

This would be amazing. I'm starting to have close menu buttons within mega menus more often so that would make life a lot easier.