[BUG] Keydown event because it had an old focus tree
Hey I've noticed strange behaviour.
Demo: https://codesandbox.io/s/react-hotkeys-6vexl?fontsize=14
If we focus "container 1" and press esc we'll see "Container 1 ESC" that is ok. If we press the "change" button we'll show "container 2" and after focus it and press ESC in the console we'll see "Container 2 ESC" - like expected.
And now we can change focus as much as we want. We can show and hide container 2 by button and everything work as expected.
Bug But... Container 2 got action for "enter" key. This action doing the same thing as the "change" button but by HotKeys handler. After we press "enter" key when container 2 is focused - ESC handlers don't work anymore on any container.
Strange If i add
simulateMissingKeyPressEvents: false
option. The handler will work on 3rd ESC press
Expected behavior ESC handlers work after we use "enter' when container 2 is focused.
Platform
- react-hotkeys 2.0.0
- chrome
- OS: Ubuntu
Thanks for posting your issue.
Unfortunately I do not have the time to actively work on this package, but I am seeking other active maintainers. If you are willing to create a pull request or help out, that would be an excellent way of moving this forward.