DEV Community

loading...

More elegant way to close main menu on focus/blur event

ronca85 profile image ronca85 ・1 min read

How do you handle focus and blur events when creating a keyboard accessible main navigation? Here's my code example: https://codepen.io/ronca/pen/ZEOqdvx

It works as it should but I don't know if this can be scaled without running into issues. Is there an easier approach? I want the navigation to close when focus leaves a nav item.

Thanks

Discussion (0)

pic
Editor guide