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

keydown event handler fails on gethotkeyhandler #1952

Closed
Geczy opened this issue Aug 1, 2022 · 1 comment
Closed

keydown event handler fails on gethotkeyhandler #1952

Geczy opened this issue Aug 1, 2022 · 1 comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)

Comments

@Geczy
Copy link

Geczy commented Aug 1, 2022

What package has an issue

@mantine/hooks

Describe the bug

i want to use the usehotkeys hook but since that only works in input fields i cant, so i have to use gethotkeyhandler sadly

prefer instead if usehotkeys has a setting to enable or disable input fields like here https://react-hotkeys-hook.vercel.app/docs/api/use-hotkeys

enableOnTags: false // <-- what i need

but the bug is this:

  document.body.addEventListener("keydown", getHotkeyHandler([
        ['mod+Enter', handleSubmit],
        ['mod+S', handleSave],
      ]));

TypeError: Cannot destructure property 'altKey' of 'event' as it is undefined.

Argument of type '(event: KeyboardEvent) => void' is not assignable to parameter of type 'EventListenerOrEventListenerObject'.
Type '(event: KeyboardEvent) => void' is not assignable to type 'EventListener'.
Types of parameters 'event' and 'evt' are incompatible.
Type 'Event' is missing the following properties from type 'KeyboardEvent': altKey, charCode, ctrlKey, code, and 15 more.

What version of @mantine/hooks page do you have in package.json?

4.6.0

If possible, please include a link to a codesandbox with the reproduced problem

No response

Do you know how to fix the issue

No

Are you willing to participate in fixing this issue and create a pull request with the fix

No

Possible fix

No response

@Geczy Geczy added the bug label Aug 1, 2022
@rtivital rtivital added Fixed patch Completed issues that will be published with next patch (1.0.X) and removed bug labels Aug 11, 2022
rtivital added a commit that referenced this issue Aug 13, 2022
@rtivital
Copy link
Member

Added in 5.1.5, getHotkeyHandler now can be added to any dom node with .addEventListenerhttps://mantine.dev/hooks/use-hotkeys/#targeting-elements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed patch Completed issues that will be published with next patch (1.0.X)
Projects
None yet
Development

No branches or pull requests

2 participants