Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Key released still pressed if the focus is lost #307

Open
ds4biz opened this issue Apr 30, 2021 · 1 comment
Open

[BUG] Key released still pressed if the focus is lost #307

ds4biz opened this issue Apr 30, 2021 · 1 comment

Comments

@ds4biz
Copy link

ds4biz commented Apr 30, 2021

Describe the bug
If I press a key that open for example a dialog (that makes the Hotkeys component wrapper to lose focus) when the dialog is closed the key pressed for open it is still pressed when I try to use other mapped hotkeys.
This is a basic reproduction: CODESANDBOX

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

Expected behavior
When the component lose focus keys pressed should be reset or refreshed, and at least a method to do it manually

Platform (please complete the following information):

  • Version of react-hotkeys: 2.0.0
  • Browser [e.g. chrome, safari] Chrome
  • OS: [e.g. iOS] MacOs

Are you willing and able to create a PR request to fix this issue?
I don't think

Include the smallest log that includes your issue:

HotKeys (F1📗-E5🧡-C1⭐️-P0🔺:) New 'Delete' keydown event.
HotKeys (F1📗-E5🧡-C0🔺) Found action that matches 'Delete': DELETE. Calling handler . . .
HotKeys (F1📗-E5🧡-C0🔺) Stopping further event propagation.
HotKeys (F1📗-E7💚-C1⭐️-P0🔺:) New (simulated) 'Delete' keypress event.
HotKeys (F1📗-C1⭐️-P0🔺:) Received new props.
HotKeys (F1📗-C1⭐️-P0🔺:) Lost focus.    -----> THIS HAPPENS WHEN DIALOG OPENS
HotKeys (F2📘-C1⭐️-P0🔺:) Focused.       -----> THIS HAPPENS WHEN I CLOSE DIALOG
HotKeys (F2📘-E8💙-C1⭐️-P0🔺:) New 'Escape' keydown event
HotKeys (F2📘-E8💙-C0🔺) No matching actions found for 'Delete+Escape' keydown.     -----> I JUST PRESS "DELETE"
HotKeys (F2📘-E10💜-C1⭐️-P0🔺:) New (simulated) 'Escape' keypress event.
HotKeys (F2📘-E11🧡-C1⭐️-P0🔺:) New 'Escape' keyup event.
HotKeys (F2📘-E11🧡-C0🔺) No matching actions found for 'Delete+Escape' keyup.     -----> WRONG KEYS COMBO TRIGGERED (DELETE IS NOT STILL PRESSED)
@smalldazzy
Copy link

Having the same issue, but with Enter. KeyUp event is being simulated and ignored somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants