Closed benoitgrelard closed 4 years ago
Double checked with a real modals - and, you are right, it's bound to keydown
.And I would greatly appreciate if you draft a PR.
Cool, just sent a PR: https://github.com/theKashey/react-focus-on/pull/16
Released as 3.0.7
Hi @theKashey,
Looking at what the OS does for all types of modal layers (things like save dialog, confirmation dialogs, open menus, open selects, etc) close on escape always executes instantly as soon as touching the escape key, on
keydown
basically.https://github.com/theKashey/react-focus-on/blob/master/src/Effect.tsx#L66
We are bound to
keyup
here which puts us a bit behind in terms of timing, and offers a different UX.I believe we should also bind to
keydown
rather thankeyup
?Small change, but I think offers much better consistency. Let me know your thoughts, I can do a PR if needed, although I doubt you need one considering the change.
Cheers 👍