DEV Community


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:

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.


Discussion (0)

Editor guide