negomi / react-burger-menu

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations
http://negomi.github.io/react-burger-menu/
MIT License
5.04k stars 582 forks source link

Keyboard interactions catches the focus for the entire application #438

Closed neacsugeorge closed 3 years ago

neacsugeorge commented 3 years ago

Hi there,

Since you've added the keyboard interactions, it catches the focus on any key down event even if the menu isn't focused.

We had to revert to using version 2.5.2 because it breaks our application. It didn't matter if the user was on a textarea or a simple input, pressing up/down would focus the menu.

The only way to disable this was to provide a custom onKeyDown function but that would lead to unexpected behaviours.

negomi commented 3 years ago

Hi @neacsugeorge,

Do you mean it catches the keyboard interactions while the menu is open?

That would make sense, as the menu basically assumes that if it is open, the user is interacting with it and not other page contents.

If you do want the rest of the page to be usable while the menu is open, a custom keydown handler is the way to go. Not sure what unexpected behaviours you're seeing with that, but you can still tab through all the elements even if you just pass a no-op like: customOnKeyDown={() => {}}

neacsugeorge commented 3 years ago

Hi @negomi,

Thank you for your answer.

Our application has a push menu open 90%+ of the time and having it catch the focus is problematic for us. We target desktop users.

Passing that no-op could lead to unexpected behaviours.

negomi commented 3 years ago

Hey @neacsugeorge,

The no-op should not cause unexpected behaviours with the rest of your app. It doesn't overwrite the global window.onkeydown, just adds an extra listener. The only thing that would be lost is the menu's 'close on escape' functionality, so you would have to implement that yourself if you still want it.

I'm going to close this out for now because I don't think this is a bug with the menu, but feel free to let me know if you have more questions.