greena13 / react-hotkeys

Declarative hotkey and focus area management for React
https://github.com/greena13/react-hotkeys
ISC License
2.15k stars 160 forks source link

[BUG] hitting space twice breaks all events #308

Closed TheYarin closed 3 years ago

TheYarin commented 3 years ago

Describe the bug I have a text input I wanted to add some hotkeys to. Everything is working fine until the second 'space' is typed. Then, all of the hotkeys cease to work. In the log (level: debug) I see that it no longer captures new keydown events since the second 'space' is typed. This behavior is fixed when I set the simulateMissingKeyPressEvents configuration to false, but that breaks the ctrl+alt+enter hotkey which I'm also using so it's not good enough.

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys etc) HotKeys component

Expected behavior I expect the hotkeys to continue working even after hitting the space bar twice.

Platform (please complete the following information):

Are you willing and able to create a PR request to fix this issue? Probably not, sorry.

Include the smallest log that includes your issue: I type 'f' and then space twice. On the second space, hotkeys stop working.

HotKeys (F1📗-E1💚-C1⭐️-P2🔷:) New 'f' keydown event.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E1💚-C0🔺-P3🔶:) No matching actions found for 'f' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E1💚-C1⭐️-P2🔷:) No matching actions found for 'f' keydown.
2AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E1💚-C2🔷-P1⭐️:) No matching actions found for 'f' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E1💚-C3🔶-P0🔺:) No matching actions found for 'f' keydown.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E2💙-C1⭐️-P2🔷:) New 'f' keypress event.
FocusOnlyKeyEventStrategy.js:188 HotKeys (F1📗-C3🔶-P0🔺:) Received new props.
FocusOnlyKeyEventStrategy.js:188 HotKeys (F1📗-C2🔷-P1⭐️:) Received new props.
FocusOnlyKeyEventStrategy.js:188 HotKeys (F1📗-C1⭐️-P2🔷:) Received new props.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E3💛-C1⭐️-P2🔷:) New 'f' keyup event.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E4💜-C1⭐️-P2🔷:) New ' ' keydown event.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E4💜-C0🔺-P3🔶:) No matching actions found for ' ' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E4💜-C1⭐️-P2🔷:) No matching actions found for ' ' keydown.
2AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E4💜-C2🔷-P1⭐️:) No matching actions found for ' ' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E4💜-C3🔶-P0🔺:) No matching actions found for ' ' keydown.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E6❤️-C1⭐️-P2🔷:) New (simulated) ' ' keypress event.
FocusOnlyKeyEventStrategy.js:339 HotKeys (F1📗-E6❤️-C0🔺-P3🔶:) Ignored (simulated) ' ' keypress as it was not expected, and has already been simulated.
EventPropagator.js:252 HotKeys (F1📗-E6❤️-C1⭐️-P2🔷:) Stopping further event propagation.
FocusOnlyKeyEventStrategy.js:339 HotKeys (F1📗-E6❤️-C1⭐️-P2🔷:) Ignored ' ' keypress as it was not expected, and has already been simulated.
EventPropagator.js:252 HotKeys (F1📗-E6❤️-Cnull🔺) Stopping further event propagation.
FocusOnlyKeyEventStrategy.js:188 HotKeys (F1📗-C3🔶-P0🔺:) Received new props.
FocusOnlyKeyEventStrategy.js:188 HotKeys (F1📗-C2🔷-P1⭐️:) Received new props.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E7💚-C0🔺-P3🔶:) New ' ' keyup event.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E8💙-C0🔺-P3🔶:) New ' ' keydown event.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E8💙-C0🔺-P3🔶:) No matching actions found for ' ' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E8💙-C1⭐️-P2🔷:) No matching actions found for ' ' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E8💙-C2🔷-P1⭐️:) No matching actions found for ' ' keydown.
AbstractKeyEventStrategy.js:429 HotKeys (F1📗-E8💙-C3🔶-P0🔺:) No matching actions found for ' ' keydown.
FocusOnlyKeyEventStrategy.js:298 HotKeys (F1📗-E10💜-C0🔺-P3🔶:) New (simulated) ' ' keypress event.
FocusOnlyKeyEventStrategy.js:339 HotKeys (F1📗-E10💜-C0🔺-P3🔶:) Ignored ' ' keypress as it was not expected, and has already been simulated.
EventPropagator.js:252 HotKeys (F1📗-E10💜-Cnull🔺) Stopping further event propagation.
FocusOnlyKeyEventStrategy.js:188 HotKeys (F1📗-C3🔶-P0🔺:) Received new props.

Any typing from this point on only logs "received new props", no events.

What Configuration options are you using?

configure({
ignoreTags: []
})

Also, allowChanges is set to true.

TheYarin commented 3 years ago

Seems like this issue was already reported, sorry for not properly checking prior to posting.