-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Feature request / how to? Close button within the mega menu #17
Comments
Good question. Right now, I don't think this is possible, but I'm actually mulling over a different-but-related issue that might make this possible soon. Hopefully I'll have an update soon. |
@ajplopez I haven't actually built out your specific use-case, but it should be possible now with the v1.2.0 I pushed out today! Here's the new feature you'll need. The gist of what you'd need to do:
As I write this out, I realize that you'll need to be careful about managing focus in this case. You presumably want to return it to the parent menu item of the open submenu, but I haven't provided any easy way to do that. (That is because I can't make a good assumption about where focus should always go since this function is intended for arbitrary use.) If it were me I would capture Let me know how it goes! If you write something you can share, it would be great to post it to this issue! |
I'm going to close this, but feel free to re-open if you try to do this and run into issues. |
This is fantastic! I did get this working for my own set up. I was a little bit confused by the myMenu because you're targeting the ul with the class "clicky-menu" and not the nav id = " primary-nav " but once I got that figured out it was working. Also, I ended up with multiple mega menus each with their own close buttons so I just targeted any button with .close-open-menus buttons and that seems to work great. It seems that once the Close menu button is clicked, the focus applies to the top level button again so that seems to work great for my setup. Thanks again! |
This is good feedback, I may tweak where that listener is so it works on either (or any child DOM node, thanks to event bubbling). I'm really glad to hear that focus is staying on the parent items. That is not what I had expected (I didn't look very hard), but that's awesome. I'd want to test that with a few different browsers to confirm. Sounds really promising! |
I'm working on a mega menu that has a "Close" button. I would like it so that the user can click on the Close button and it collapses the menu. For my purposes, the Close button markup is within the mega menu itself.
But I think because it's within the menu, clicking on the button still leaves the focus on the top level button so it doesn't close.
So it would be nice if there was a way to set an explicit close button within mega menus. Is this possible currently?
The text was updated successfully, but these errors were encountered: